I want to count the number and type of files in a bunch of subdirectories. I have code to count all the files in a single directory but not the types. I also have code to count the types of files but it's an aggregate from all the subdirectories. How can I accomplish both?
#This count all files and directories contained in the specified DIR
echo -e "Which directory to count \c"
#this lists the number of files by type
echo "Number of files in all directories by type"
find "$DIR" -type f | rev | cut -d . -f1 | rev | sort | uniq -ic | sort -rn
#this list the number of files in all the sub directories (but not separated by type)
echo "Number of files in each subdirectory (but not by type)"
find "$DIR" -type f -execdir pwd \; | uniq -c