Ask Different is a question and answer site for power users of Apple hardware and software. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.)?

share|improve this question

If the files are indexed by Spotlight and files in subdirectories can be included, you could use mdfind:

mdfind kMDItemFSInvisible=1 -onlyin .

Or test for both GetFileInfo -av (attribute invisible) and if the name starts with a period:

shopt -s dotglob nullglob
for f in *; do [[ $(GetFileInfo -av "$f") = 1 || $f = .* ]] && echo "$f"; done

GetFileInfo is part of the command line tools package that can be downloaded from Xcode's preferences or from

Different ways to list only files that start with a period:

shopt -s nullglob; printf %s\\n .[^.]* ..?*
shopt -s dotglob nullglob; GLOBIGNORE='. ..'; printf %s\\n *
ls -a | grep -E '^(\.[^.]|\.\.[^$])'
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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