Unexpected bash directory listing with *
Asked Answered
H

2

9

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 ?

Hotspur answered 12/1, 2012 at 0:50 Comment(0)
Z
9

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
Zosi answered 12/1, 2012 at 0:53 Comment(0)
Y
2

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.

Yamen answered 12/1, 2012 at 1:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.