1

Let's say I want to find all files in a directory (recursively), but omit those e.g. in .git and node_modules subdirectories. I can do:

$ fd -uut f -E .git -E node_modules

But that will, for example, exclude ./some/dir/node_modules/* or some such.

In this case that's probably okay, but I don't want to consider every time I need to find something whether non-anchored search will do. Not to mention that in some cases it won't.

How do I exclude ./dir, but not ./**/dir?

x-yuri
  • 3,223
  • 10
  • 39
  • 62

1 Answers1

1

To differentiate amongst the two cases, make use of the -path predicate:

$ find . -path ./a -prune -o -type f -print
Kusalananda
  • 320,670
  • 36
  • 633
  • 936
guest_7
  • 5,698
  • 1
  • 6
  • 13