3

I would like to list all the non-hidden files and directories in my path.

This means that files beginning with . should be excluded from the result, along with files whose path contains a hidden directory:

foo/bar/.bazz.rc # Exclude
foo/.bar/bazz.rc # Exclude

How do I do that? I've tried:

find -maxdepth 2 -not -iname "*/.*"

But I still have hidden files in my results.

2

Escape the dot and use path instead of iname:

find .  -not -path "*/\.*"
  • * - any prefix
  • / - directory/file separator
  • \. - escaped ..
  • * - any suffix

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.