tiago tiago - 1 year ago 55
Bash Question

Script to count number of files in each directory

I need to count the number of files on a large number of directories. Is there an easy way to do this with a shell script (using find, wc, sed, awk or similar)? Just to avoid having to write a proper script in python.

The output would be something like this:

$ <magic_command>
dir1 2
dir2 12
dir3 5

The number after the dir name would be the number of files. A plus would be able to turn counting of dot/hidden files on and off.