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/
David542
  • 104,438
  • 178
  • 489
  • 842

1 Answers1

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.

David542
  • 104,438
  • 178
  • 489
  • 842
Charles Duffy
  • 280,126
  • 43
  • 390
  • 441