Reputation: 1833
I have a command that looks through all my sub folders for files, however I want it to skip a folder from the search and I'm not sure what is the right way to do this:
find -name '*.avi' -o -name '*.mkv' -o -name '*.mp4' -o -name '*.vob'
I want it to not look into the folder name: secure
I tried:
find -name '*.avi' -o -name '*.mkv' -o -name '*.mp4' -o -name '*.vob' --skip 'secure'
but it does not work.
Thanks for your help in advance.
Upvotes: 0
Views: 887
Reputation: 12051
There is no --skip argument in GNU find. But you can do what you want using the -path
and -prune
expressions. The syntax is a little weird: you use -path ./secure -prune
as a term which you then OR with the rest of the expression. So in your case:
find . -name '*.avi' -o [...] -o -path ./secure -prune
Note that this will still return the directory ./secure
in the results, but nothing inside it.
Upvotes: 6
Reputation: 9930
What about the following?
find \( -name '*.avi' -o -name '*.mkv' -o -name '*.mp4' -o -name '*.vob' \) -a -not -path './secure*'
Upvotes: 1