Short reason: the string ./.ignoramus
is not matching .ignoramus
.
Short solution: use GLOBIGNORE=*ignoramus
(also read detail at the end).
$ GLOBIGNORE=*ignoramus
$ ls .* | grep ignor ### empty
$ ls ./.* | grep ignor ### also empty
The asterisk will match anything (even an slash /
before the name).
Of course, that will also match foobar.ignoramus
.
For a couple of workarounds read at the end.
Expanded answer:
That also happens with a normal file:
$ mkdir /tmp/mytest; cd /tmp/mytest
$ touch f1 f2 filetotest
$ GLOBIGNORE=filetotest
$ ls -1
f1
f2
filetotest
$ ls -1 f*
f1
f2
$ ls -1 *
f1
f2
$ ls -1 ./f*
./f1
./f2
./filetotest
GLOBIGNORE will not match ./filetotest
, but if we use:
$ GLOBIGNORE="*filetotest"
$ ls -1 ./f*
./f1
./f2
$ ls -1 ./*
./f1
./f2
$ ls -1
f1
f2
filetotest
The pattern in GLOBIGNORE will match (something)filetotest
.
For your example:
$ touch .ignoramus
$ GLOBIGNORE='*ignoramus'
ls -1a
.
..
f1
f2
filetotest
.ignoramus
$ ls .* | grep ignor
$ ls ./.* | grep ignor
Even with some path in front of file, it works:
$ GLOBIGNORE='*ignoramus:*filetotest'
$ mkdir -p long/dir/to/test
$ touch long/dir/to/test/{f3,f4,.ignoramus,.other,filetotest}
$ ls -1 long/dir/to/test/f*
long/dir/to/test/f3
long/dir/to/test/f4
$ ls -1 long/dir/to/test/.[^.]*
long/dir/to/test/.other
$ shopt -s dotglob
$ ls -1 long/dir/to/test/*
long/dir/to/test/f3
long/dir/to/test/f4
long/dir/to/test/.other
$ unset GLOBIGNORE; shopt -s dotglob
$ ls -1 long/dir/to/test/*
long/dir/to/test/f3
long/dir/to/test/f4
long/dir/to/test/filetotest
long/dir/to/test/.ignoramus
long/dir/to/test/.other
Of course, that will also match bar.ignoramus
. If that is not desired, use:
$ GLOBIGNORE=.ignoramus:./.ignoramus
Or, if you want any path included:
$ GLOBIGNORE=.ignoramus:*/.ignoramus