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.
Just a question out of curiosity, is it possible to ignore case without globbing?
ls a would output both a and A
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.