I'm trying to list all JPG files inside a directory tree to create a report of JPG files inside this tree without search inside every directory one by one.

The command I'm using is this one:

ls -lhAR | grep jpg

The command didn't work as I spected because it just showed me the list of JPG files but didn't show me their path.

There's any way to acomplish what I'm looking for?

  • Do you just need the paths, or do you need the other information given by less -l as well?
    – lzam
    Sep 3, 2014 at 2:23
  • I just need the paths, and the answer @John1024 gave did a really good work.
    – Dave Gomez
    Sep 30, 2014 at 16:35

2 Answers 2

find . -iname '*.jpg' -exec ls -lhA {} +
  • It worked beautifully
    – Dave Gomez
    Sep 3, 2014 at 3:08

Using recursive globbing (**) this command should do the trick:

ls -lhA **/*.jpg

This works by default in zsh; when you use bash (version 4 or above) you need to enable those advanced globbing patterns via

shopt -s globstar

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.