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
info page mention Regular Expressions.
Question: Which wildcards or Regular Expressions are supported in
ls --hide= and
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?
From the manual:
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
.., 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.