0

The question is itself self-explanatory.

I tried the following command I found somewhere on the internet but it shows the number just in the immediate directory and not its subdirectories.

ls -lR ./*.jpg | wc -l

I am searching for all the files with the extension ".jpg" in the current folder and its subdirectories.

  • 1
    I would suggest using find, refer to [this](https://stackoverflow.com/questions/14827686/list-of-all-folders-and-sub-folders#14827721) answer for more information – maplesyrupman Jun 16 '21 at 18:25

2 Answers2

1
find . -type f -name '*.jpg' | wc -l

Find all the files (type f) that have a name that matches '*.jpg' then count them with wc

Jad
  • 1,257
  • 12
  • 19
1

It's a job for find:

find -name "*.jpg" | wc -l
pff
  • 11
  • 1