I would like a BASH command to list just the count of files in each subdirectory of a directory.
E.g. in directory
/tmp there are
dir2, ... I'd like to see :
`dir1` : x files `dir2` : x files ...
Assuming you want a recursive count of files only, not directories and other types, something like this should work:
Using find is definitely the way to go if you want to count recursively, but if you just want a count of the files directly under a certain directory:
This task fascinated me so much that I wanted to figure out a solution myself. It doesn't even take a while loop and MAY be faster in execution speed. Needless to say, Thor's efforts helped me a lot to understand things in detail.
So here's mine:
It looks modest for a reason, for it's way more powerful than it looks. :-)
However, should you intend to include this into your
Note the very tricky handling of nested single quotes. And no, it is not possible to use double quotes for the