1

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
    Why don't you use the -prune option as indicated in the accepted answer in the post you link to? – Anthon Apr 24 '16 at 15:29
  • I just can't get the syntax working: find .//. ! -name @eaDir -prune -print | grep -c // – Arthur Frankel Apr 24 '16 at 15:43
2

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)

  • With the ! ( which works as not ...) the toplevel would get pruned and you end up with 0 – Anthon Apr 24 '16 at 16:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.