$ mkdir temp && cd temp
$ ls [0-9]
ls: cannot access '[0-9]': No such file or directory
$ touch \[0-9\]
$ ls [0-9]
'[0-9]'
$ touch 1
$ ls
1 '[0-9]'
$ ls [0-9]
1
I find this behavior very surprising. To me, the [0-9]
glob pattern should only match a file whose name consists of a single numeric digit. But it is also sometimes matching a file named [0-9]
itself.
Is this a bug with glob expansion in bash?
Can I disable this, so that [0-9]
never matches [0-9]
(as it shouldn't)?
ls
print a leading space? – Pedro A Sep 27 '20 at 01:09zsh
by default settings. – binarysta Sep 27 '20 at 01:14ls
add a leading whitespace to its output for certain directories? – steeldriver Sep 27 '20 at 01:19