Unexpected bash directory listing with *

193 Views Asked by At

I have a issue with case sensitive directory listing in my bash. for example

   $ touch  nohupa nohuPb
   $ ls nohup*
   nohupa  nohuPb

However I do expect it only list nohupa not nohuPb. because nohuPb has capital P. I don't know what variable in my .bashrc set that * works ignore case.

Any idea ?

2

There are 2 best solutions below

0
On BEST ANSWER

It's nocaseglob that causes that.

nocaseglob
If set, bash matches filenames in a case-insensitive fashion when performing pathname expansion (see Pathname Expansion above).

testing

$ touch fooab fooAb
$ ls
fooAb fooab
$ shopt -s nocaseglob
$ ls fooa*
fooAb fooab
$ shopt -u nocaseglob
$ ls fooa*
fooab
0
On

Looks like your shell has the nocaseglob set. You can unset it by using a shell built-in called shopt. Use -s option to enable it and -u option to disable it.

For more reference you can visit here.