I use the shopt -s nocaseglob command to ignore case, but it seems like it doesn't work if I use a string without glob.

enter image description here

Just a question out of curiosity, is it possible to ignore case without globbing? i.e. ls a would output both a and A


Not with ls no. You could, however, use something like these:

$ ls [Aa]
$ find . -iname a
$ echo [aA]

The reason behind this is that the shopt command only affects how globs are expanded by the shell. So, when you run ls *a after running the shopt command, that gets expanded by your shell to

ls a A 

So, as @Kevin said, the glob is expanded before being passed to ls, therefore the nocaseglob will have no effect when you give a simple string and not a glob.


No. Glob expansion is handled by the shell before ls is even invoked.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.