"find" files in the current directory, but skip some specific subdirectories

I wonder how to specify the command find

to search for files in the current directory, but skip some specific subdirectories.

For example, I would like to skip subdirectories that match ./dir1/*.1/

.

If I wanted to exclude directories that correspond to ./dir1/train*.1/

, ./dir2/train*.3/

, ./dir1/dir3/train*.2/

... I can point them all? I tried -path '\*/train*.*' -prune

it but it doesn't work.

+2


a source to share


2 answers


You need to use an option -path

and -prune

for example:



find . -type d -path "./dir1/*.1" -prune -o -print

      

+7


a source


Check this one . EDIT: Straight from the man page: `To ignore the directory and files under it, use -prune '.



+2


a source







All Articles