1

I have the following find command:

find /mnt/F_11 -type f \( -iname '*.xls' -o -iname '*.xlsx' /)

How would I find all items in /mnt/F_11 but not in /mnt/f_11/DONOTENTER/?

In other words, I would want it to search:

YES /mnt/F_11
YES /mnt/F_11/somepath/
YES /mnt/F_11/somepath/other/
NO  /mtn/F_11/DONOTENTER/
0

1 Answer 1

3

Use -prune to avoid recursing down branches you don't want to follow.

find /mnt/F_11 -name DONOTENTER -prune -o \
     -type f \( -iname '*.xls' -o -iname '*.xlsx' \) -print

Note the explicit -print at the end -- this is important, as otherwise the implicit print action covers both branches.

Sign up to request clarification or add additional context in comments.

2 Comments

would that be faster than doing -not -path /mnt/F_11/DONOTENTER* ?
Yes, because -prune stops recursion down a path, whereas the other approach given would test contents within that subtree.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.