Note that it's not ls
that expands wildcards, it's the shell.
bash
can make all its globs case insensitive with the nocaseglob
option, but contrary to ksh93
or zsh
doesn't have a glob operator for having a single glob or part of a single glob case insensitive.
However, you can always do:
ls -ld -- *.[jJ][pP][gG]
Which also has the benefit of not leaving it up to the locale to decide what is the lower or upper case variant of a given letter (for instance, is the upper case variant of gif
GIF
or GİF
?).
Or with the extglob
option to also cover jpeg
:
ls -ld -- *.[jJ][pP]?([eE)[gG]
With zsh
, and with the extendedglob
option (set -o extendedglob
):
ls -ld -- *.(#i)jp(e|)g
With ksh93
:
ls -ld -- *.~(i)jp?(e)g
Or:
ls -ld -- *.~(i:jp?(e)g)