ls --hide and ls --ignore provides the possibility leave out files defined through regular expressions set after the --ignore= part. The latter makes sure that this option isn't turned off via -a, -A. The command's man and info page mention Regular Expressions.

Question: Which wildcards or Regular Expressions are supported in ls --hide= and ls --ignore=.

I found out that * $ ? seem to be supported, as well as POSIX Bracket Expressions. But this doesn't seem to work properly all the time and is more a game of trial and error for me. Did I miss something important here?

  • 2
    related: unix.stackexchange.com/questions/26900/…
    – slm
    Jun 15, 2013 at 21:40
  • Somewhat related, but this question is specifically about --ignore whereas the question you cited is about emacs and --ignore is only mentioned in passing in the answer.
    – bahamat
    Jun 15, 2013 at 21:45

2 Answers 2


From the manual:

-I pattern, --ignore=pattern

In directories, ignore files whose names match the shell pattern (not regular expression) pattern. As in the shell, an initial . in a file name does not match a wildcard at the start of pattern. Sometimes it is useful to give this option several times. For example,

     $ ls --ignore='.??*' --ignore='.[^.]' --ignore='#*'

The first option ignores names of length 3 or more that start with ., the second ignores all two-character names that start with . except .., and the third ignores names that start with #.

You can use only shell glob patterns: * matches any number of characters, ? matches any one character, […] matches the characters within the brackets and \ quotes the next character. The character $ stands for itself (make sure it's within single quotes or preceded by a \ to protect it from shell expansion).


It uses POSIX.2 regex pattern format. See the re_format(7) man page for specific details.

  • this is what I meant with POSIX Bracket Expression, exactly :)
    – erch
    Jun 15, 2013 at 21:59
  • I guess what I really meant was to tell you to just read the man page.
    – bahamat
    Jun 16, 2013 at 6: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.