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 '14 at 2:23
  • I just need the paths, and the answer @John1024 gave did a really good work. – Dave Gomez Sep 30 '14 at 16:35
find . -iname '*.jpg' -exec ls -lhA {} +
| improve this answer | |
  • It worked beautifully – Dave Gomez Sep 3 '14 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
| improve this answer | |

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.