简体   繁体   中英

find all but skip one folder

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.

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.

接下来呢?

find \( -name '*.avi' -o -name '*.mkv' -o -name '*.mp4' -o -name '*.vob' \) -a -not -path './secure*'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM