Another method would be:-
Code:
ls -lC1R | sed -e '/.*:\|^$/d' | sort | uniq -c
This will provide the information you require in this format:-
Code:
2 dir_a
4 dir_b
2 dir_c
1 dir_d
1 dir_f
2 file_a
3 file_b
1 file_c
where the first field is the number of occurences and the second field is the file/dir name.
It will not differentiate between files and directories, so if you want to do this check out "man ls" for file listing options. This is probably a good idea, otherwise if you have a file called "dog" and a directory called "dog" it will count them both in the same line.
When you format the output I would suggest putting something between the file name and the number of occurences, otherwise if you have a listing with "pic123", for example, how would you know if it is 3 x "pic12" or 23 x "pic1" or even 123 x "pic"?