This is actually done by your shell, not by
bash, you’d use:
shopt -s nocaseglob
and then run your command.
Or in yash:
set +o case-glob
and then your command.
You might want to put that into
Alternatively, with zsh:
setopt extendedglob ls -d -- (#i)*abc*
(that is turn case insensitive globbing on a per-wildcard basis)
ls -d -- ~(i:*abc*)
You want globbing to work different, not
ls, as those are all files passed to
ls by the shell.
As explained by polemon, it is the shell (not ls) that extends
*abc* to a list of files. This is called Pattern Matching.
Aside from changing the whole Pattern Matching behavior to ignore case, you could use another form of pattern matching than the
*. The following would do what you want in bash:
From bash man:
[…] Matches any one of the enclosed characters.
This allows more fine grain matching where you could use
*[aA][bB]c* to match
ABc but not
ABC. Or an example in French, where I could want to match all instances of the
You can also add
-i (–ignore-case) option to
grep to get and the below output.
[root@localhost ~]# ls -l | grep -i abc -rw-r--r-- 1 root root 0 Feb 25 20:41 fileabc.txt -rw-r--r-- 1 root root 0 Feb 25 20:41 fileABC.txt