I would like to list all files matching a certain pattern while ignoring the case.
For example, I run the following commands:
ls *abc*
I want to see all the files that have "abc" as a part of the file name, ignoring the case, like
-rw-r--r-- 1 mtk mtk 0 Sep 21 08:12 file1abc.txt
-rw-r--r-- 1 mtk mtk 0 Sep 21 08:12 file2ABC.txt
Note
I have searched the man page for case, but couldn't find anything.
Best Answer
This is actually done by your shell, not by
ls
.In
bash
, you'd use:and then run your command.
Or in
zsh
:Or in yash:
and then your command.
You might want to put that into
.bashrc
,.zshrc
or.yashrc
, respectively.Alternatively, with zsh:
(that is turn case insensitive globbing on a per-wildcard basis)
With ksh93:
You want globbing to work different, not
ls
, as those are all files passed tols
by the shell.