case insensitive, list files in directory, ending in .jpg [duplicate]
Clash Royale CLAN TAG#URR8PPP
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?
bash ls wildcards case-sensitivity
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.
add a comment |
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?
bash ls wildcards case-sensitivity
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.
add a comment |
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?
bash ls wildcards case-sensitivity
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
bash ls wildcards case-sensitivity
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.
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
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)
add a comment |
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.)
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
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)
add a comment |
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)
add a comment |
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)
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)
answered Dec 16 at 16:58
Stéphane Chazelas
299k54563913
299k54563913
add a comment |
add a comment |
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.)
add a comment |
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.)
add a comment |
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.)
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.)
edited Dec 16 at 16:41
ilkkachu
55.5k783151
55.5k783151
answered Dec 16 at 16:13
ctrl-alt-delor
10.8k41957
10.8k41957
add a comment |
add a comment |