Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unix - Count Number of file types recursively

I am new to Stack Overflow and am somewhat of a newbie with Linux. I have been trying to filter specific files within a parent directory and it's children using the following command as an example:

ls -R | grep '*.jpg' | wc -l

Which I have found great when looking for individual files but I will need to do this on a monthly basis and looking for quicker ways to list several types in one command. I purposely want to exclude hidden files.

I have tried this but to no avail — Count number of specific file type of a directory and its sub dir in mac

I've seen different methods across the web from list, find, tree, echo etc. so any help with this would be much appreciated and if there is a better way of doing this than what I am currently doing then that's not a problem as I am open to suggestions. I'm just not sure what's the best way to skin this cat at the moment!

Thank you very much

like image 998
Pampa Avatar asked May 26 '15 10:05

Pampa


1 Answers

you can do this with help of find as it was mentioned under the link from your initial post. Just something like this:

find . -name \*.jpg -or -name \*.png -not -path \*/\.\* | wc -l
like image 90
Dieselist Avatar answered Nov 08 '22 23:11

Dieselist