I wonder how to specify to the command find
for searching files under current directory but skipping some specific sub-directories.
For example, I would like to skip sub-directories that match ./dir1/*.1/
.
If I would like to exclude subdirectories that match ./dir1/train*.1/
, ./dir2/train*.3/
, ./dir1/dir3/t开发者_运维问答rain*.2/
..., how can I specify all of them? I tried -path '\*/train*.*' -prune
but it does not work.
You need to use the -path
option and the -prune
option, like this:
find . -type d -path "./dir1/*.1" -prune -o -print
Check this out. EDIT: Straight from the man page: `To ignore a directory and the files under it, use -prune'.
精彩评论