Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

Re: Find all JPEG files in a directory

by gri6507 (Deacon)
on Aug 11, 2005 at 20:29 UTC ( #483119=note: print w/replies, xml ) Need Help??

in reply to Find all JPEG files in a directory

I know you want to do this a perl-ish way, but such a task could be just as easily be done from the command line -  find . | grep jpg

Replies are listed 'Best First'.
Re^2: Find all JPEG files in a directory
by extremely (Priest) on Aug 12, 2005 at 13:21 UTC
    "grep jpg"? No login for you on my systems. :) One of these will actually find most if not all of the files with a JPEG extension without matching files like "not_a_jpg.gif". Whenever you have a fairly simple match, you'll come out ahead using the find built-ins rather than piping to grep.

    find . -name '*.jpg' -o -name '*.jpeg' -o -name '*.JPG' -o -name '*.JPEG'

    find ./ -name '*.[Jj][Pp][Gg]' -o -name '*.[Jj][Pp][Ee][Gg]'

    And if you must use grep, do it right!

    find . | grep -i '[.]jpe\?g$'

    find . | egrep -i '[.]jpe?g$'

    $you = new YOU;
    honk() if $you->love(perl)

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://483119]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (5)
As of 2018-06-19 23:11 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (116 votes). Check out past polls.