Say I have the following tree:
root:
d foo
d bar
/foo:
d A
- tmp.txt
/bar:
d B
- tmp2.txt
/foo/A:
- tmp3.txt
/bar/B:
d = directory and - = file
I need to answer the following question: which directory (excluding the root) contains the least entries?
I have tried
find . | grep -oE '/([a-zA-Z]+/)+'
to get the number of occurrences for each directory. The problem is this command exclude empty directories, in this case /bar/B is excluded.
Any guidance on how to solve this would be appreciated.