Bash Pattern Matching

I am trying to use pattern matching to find all files in a directory that has a .jpg or jpeg extension.

ls *.[jJ][pP][eE][gG]<- this will obviously only find the .jpeg file extension. The question is how to make it [eEoptional?

+5
source share
2 answers

Match harder.

ls *.[jJ][pP]{[eE],}[gG]
+6
source

Like the standard (simple) glob templates, bash β‰₯4.0 has an extended pullup. Disabled by
default . To enable it, use:shopt -s extglob

extglob , . , glob , glob, . , : shopt -s nocaseglob

extglob . . , . , , , ?(e). - glob, .

- , , :

shopt -s extglob nocaseglob
ls -l *.jp?(e)g

: Bash .

+2