How to count number of files in each directory? November 12, 2022 by Tarik This prints the file count per directory for the current directory level: du -a | cut -d/ -f2 | sort | uniq -c | sort -nr