This has nothing to do with man pages themselves: it's a description of the syntax of glob patterns, which the man page you're looking at is about.
In a glob pattern, brackets delimit a character set. For example [abc]
matches any of the characters a
, b
or c
. The pattern fo[abc]
matches foa
, fob
and foc
(but not e.g. foo
, or fo
, or foab
).
Inside the brackets, the character -
has a special meaning: it is used to form a character range. So rather than matching 0
, -
or 9
, the pattern [0-9]
matches any digit. Ranges can be combined with other ranges and lone characters; for example [A-Za-z_]
in the ASCII encoding matches any letter or an underscore.
The minus sign is only interpreted as a range indicator when this would be syntactically sensible: if it's the first or last character inside the brackets, or if it comes immediately after another range, -
stands for itself. So in [--0]
, the first -
stands for itself and the second -
is a range indicator, therefore this pattern matches any character that is between -
and 0
in the current locale.
In the ASCII encoding, this range covers the following 4 characters: -
, .
, /
, 0
. The character /
cannot appear inside a file name, because it is always interpreted as a directory separator; therefore the pattern [--0]
matches only the 3 characters -
, .
and 0
.
Note that in locales other than ASCII, the pattern could match a different set of characters. The effect of locale setting on character ranges is somewhat variable between systems and applications.
Most regular expressions engines use the same syntax for character ranges as shell glob patterns, with two differences:
- In a glob pattern, if the first character after the opening bracket is a
!
, the pattern matches all characters that are not in the set. In a regular expression, the character ^
plays the same role. Some shells support ^
as well as !
.
- Some regular expression variants allow
\
to make the next character lose its special meaning, e.g. [\[\]\-a]
matches [
, ]
, -
or a
. In other regular expression variants and in glob patterns, a backslash in character sets has no special meaning. If ]
is in the set, it must come first (it's impossible to specify an empty set: []
is an incomplete pattern, matching a closing bracket or any character that comes afterwards).