case insensitive, list files in directory, ending in .jpg [duplicate]
up vote
0
down vote
favorite
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 yesterday
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 |
up vote
0
down vote
favorite
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 yesterday
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 |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
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 yesterday
mrflash818
18517
18517
asked yesterday
Steve Wright
11
11
marked as duplicate by don_crissti, jimmij, Rui F Ribeiro, Fabby, GAD3R yesterday
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 yesterday
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
up vote
4
down vote
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 |
up vote
3
down vote
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
up vote
4
down vote
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 |
up vote
4
down vote
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 |
up vote
4
down vote
up vote
4
down vote
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 yesterday
Stéphane Chazelas
298k54562909
298k54562909
add a comment |
add a comment |
up vote
3
down vote
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 |
up vote
3
down vote
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 |
up vote
3
down vote
up vote
3
down vote
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 yesterday
ilkkachu
55.1k782150
55.1k782150
answered yesterday
ctrl-alt-delor
10.5k41955
10.5k41955
add a comment |
add a comment |