Reputation: 8047
I was looking for "*.py" files, and exclude both "build" and "bin" directories. I used this command:
find * -path "build" -prune -path "bin" -prune -o -type f \( -name "*.py" \) -print > findpyfiles.txt
The "findpyfiles.txt" still contains results started with "bin/". How to fix it?
Upvotes: 0
Views: 82
Reputation: 19375
Although the question has an answer elsewhere, it may be worth knowing why your command didn't work right: You omitted an operator between -path "build" -prune
and -path "bin" -prune
, and -and
is assumed where the operator is omitted, thus the -path "bin"
is not evaluated when -path "build"
returns false. Explicitly specifying the OR operator fixes it, either
find * -path build -prune -o -path bin -prune -o -type f -name "*.py" -print >findpyfiles.txt
or
find * \( -path build -o -path bin \) -prune -o -type f -name "*.py" -print >findpyfiles.txt
Upvotes: 1