unix command list folders file counts

May 25, 2016 by Linux Guru

Filed under Application

Last modified June 14, 2016

unix command list folders file counts

I want to get a list of folders at the current level (not including their subfolders) and simply print the folder name and a count of the number of files in the folder (preferably filtering to *.jpeg if possible), unix command list folders file counts

I’ve come up with this one:

$vi count.sh

find -maxdepth 1 -type d | while read dir; do
count=$(find “$dir” -maxdepth 1 -iname \*.jpeg | wc -l)
echo “$dir ; $count”
done

$sh count.sh > count-`date +”TIME:%H:%M:%S”`.txt

redirecting output in count-TIME:15:40:55.txt file.

that’s how we get unix command list folders file counts

Leave a Comment