Is there a way to show only the hidden and invisible files in a directory using the command line?
For instance ls -a | grep "^\."
will show all the files hidden by a period as the first character, but what about files hidden with the invisible flag or listed in .hidden (mostly deprecated in practice, don't worry about that one so much.)?
Best Answer
If the files are indexed by Spotlight and files in subdirectories can be included, you could use mdfind:
Or test for both GetFileInfo -av (attribute invisible) and if the name starts with a period:
GetFileInfo is part of the command line tools package that can be downloaded from Xcode's preferences or from developer.apple.com/downloads.
Different ways to list only files that start with a period: