case insensitive, list files in directory, ending in .jpg [duplicate]

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP












0















This question already has an answer here:



  • How to match case insensitive patterns with ls?

    7 answers



I'm trying to write an alias to list all the files in a directory ending in JP(E)G in its various forms. The ones I'm looking for it to recognise are .jpg .JPG .jpeg and .JPEG.



Is there a form of ls (or ls in combination with another command, such as find or grep) that will do this?










share|improve this question















marked as duplicate by don_crissti, jimmij, Rui F Ribeiro, Fabby, GAD3R Dec 16 at 17:07


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.



















    0















    This question already has an answer here:



    • How to match case insensitive patterns with ls?

      7 answers



    I'm trying to write an alias to list all the files in a directory ending in JP(E)G in its various forms. The ones I'm looking for it to recognise are .jpg .JPG .jpeg and .JPEG.



    Is there a form of ls (or ls in combination with another command, such as find or grep) that will do this?










    share|improve this question















    marked as duplicate by don_crissti, jimmij, Rui F Ribeiro, Fabby, GAD3R Dec 16 at 17:07


    This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

















      0












      0








      0


      0






      This question already has an answer here:



      • How to match case insensitive patterns with ls?

        7 answers



      I'm trying to write an alias to list all the files in a directory ending in JP(E)G in its various forms. The ones I'm looking for it to recognise are .jpg .JPG .jpeg and .JPEG.



      Is there a form of ls (or ls in combination with another command, such as find or grep) that will do this?










      share|improve this question
















      This question already has an answer here:



      • How to match case insensitive patterns with ls?

        7 answers



      I'm trying to write an alias to list all the files in a directory ending in JP(E)G in its various forms. The ones I'm looking for it to recognise are .jpg .JPG .jpeg and .JPEG.



      Is there a form of ls (or ls in combination with another command, such as find or grep) that will do this?





      This question already has an answer here:



      • How to match case insensitive patterns with ls?

        7 answers







      bash ls wildcards case-sensitivity






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Dec 16 at 16:20









      mrflash818

      18517




      18517










      asked Dec 16 at 16:06









      Steve Wright

      11




      11




      marked as duplicate by don_crissti, jimmij, Rui F Ribeiro, Fabby, GAD3R Dec 16 at 17:07


      This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.






      marked as duplicate by don_crissti, jimmij, Rui F Ribeiro, Fabby, GAD3R Dec 16 at 17:07


      This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.






















          2 Answers
          2






          active

          oldest

          votes


















          4














          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)





          share|improve this answer




























            3














            Short answer



            No. But then ls does not have a way to list file ending .jpg case sensitive or note. It is the shell that converts the *.jpg into a list of files, and passes this list to ls. Try echo *.jpg, to get some ideas of what the shell is doing.



            Long answer



            You can use find: e.g. find . -iname "*.jpg" -o -iname "*.jpeg"



            or use grep e.g. ls | grep -iE "[.]jpe?g$"



            or set your shell to have case insensitive globs: shopt -s nocaseglob (This works in Bash, see How to match case insensitive patterns with ls? for solutions for other shells.)






            share|improve this answer





























              2 Answers
              2






              active

              oldest

              votes








              2 Answers
              2






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              4














              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)





              share|improve this answer

























                4














                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)





                share|improve this answer























                  4












                  4








                  4






                  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)





                  share|improve this answer












                  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)






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Dec 16 at 16:58









                  Stéphane Chazelas

                  299k54563913




                  299k54563913























                      3














                      Short answer



                      No. But then ls does not have a way to list file ending .jpg case sensitive or note. It is the shell that converts the *.jpg into a list of files, and passes this list to ls. Try echo *.jpg, to get some ideas of what the shell is doing.



                      Long answer



                      You can use find: e.g. find . -iname "*.jpg" -o -iname "*.jpeg"



                      or use grep e.g. ls | grep -iE "[.]jpe?g$"



                      or set your shell to have case insensitive globs: shopt -s nocaseglob (This works in Bash, see How to match case insensitive patterns with ls? for solutions for other shells.)






                      share|improve this answer



























                        3














                        Short answer



                        No. But then ls does not have a way to list file ending .jpg case sensitive or note. It is the shell that converts the *.jpg into a list of files, and passes this list to ls. Try echo *.jpg, to get some ideas of what the shell is doing.



                        Long answer



                        You can use find: e.g. find . -iname "*.jpg" -o -iname "*.jpeg"



                        or use grep e.g. ls | grep -iE "[.]jpe?g$"



                        or set your shell to have case insensitive globs: shopt -s nocaseglob (This works in Bash, see How to match case insensitive patterns with ls? for solutions for other shells.)






                        share|improve this answer

























                          3












                          3








                          3






                          Short answer



                          No. But then ls does not have a way to list file ending .jpg case sensitive or note. It is the shell that converts the *.jpg into a list of files, and passes this list to ls. Try echo *.jpg, to get some ideas of what the shell is doing.



                          Long answer



                          You can use find: e.g. find . -iname "*.jpg" -o -iname "*.jpeg"



                          or use grep e.g. ls | grep -iE "[.]jpe?g$"



                          or set your shell to have case insensitive globs: shopt -s nocaseglob (This works in Bash, see How to match case insensitive patterns with ls? for solutions for other shells.)






                          share|improve this answer














                          Short answer



                          No. But then ls does not have a way to list file ending .jpg case sensitive or note. It is the shell that converts the *.jpg into a list of files, and passes this list to ls. Try echo *.jpg, to get some ideas of what the shell is doing.



                          Long answer



                          You can use find: e.g. find . -iname "*.jpg" -o -iname "*.jpeg"



                          or use grep e.g. ls | grep -iE "[.]jpe?g$"



                          or set your shell to have case insensitive globs: shopt -s nocaseglob (This works in Bash, see How to match case insensitive patterns with ls? for solutions for other shells.)







                          share|improve this answer














                          share|improve this answer



                          share|improve this answer








                          edited Dec 16 at 16:41









                          ilkkachu

                          55.5k783151




                          55.5k783151










                          answered Dec 16 at 16:13









                          ctrl-alt-delor

                          10.8k41957




                          10.8k41957












                              Popular posts from this blog

                              How to check contact read email or not when send email to Individual?

                              Displaying single band from multi-band raster using QGIS

                              How many registers does an x86_64 CPU actually have?