2

This is very similar to this question, but I need to take it a bit further. I'm using a synology drive and there are tons of @eaDir directories which I want to ignore (and the files in those directories). How can I do that?

Here's a recursive command that works great with hidden files (which I want)...but how do I alter this to exclude directories names @eaDir?

find .//. ! -name . -print | grep -c //

1 Answers1

3

If you don't want to descend into any of the directories named @eaDir then you should not use ! before -name:

 mkdir -p a/@eaDir
 mkdir -p b/c/@eaDir
 mkdir -p d/e/f
 touch a/@eaDir/xxx
 touch b/yyy
 touch b/c/@eaDir/xxx
 touch d/e/f/yyy
 find . -name '@eaDir' -prune -o -print

will give you:

.
./b
./b/yyy
./b/c
./a
./d
./d/e
./d/e/f
./d/e/f/yyy

and

find .//. -name '@eaDir' -prune -o -print | grep -c // 

will give you: 9

If the name matches -name '@eaDir' then the rest of the tree underneath is skipped ('-prune') otherwise the name is printed (-o -print)

Anthon
  • 79,293