LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   how to list the number of files in serveral sub-directories (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-list-the-number-of-files-in-serveral-sub-directories-726395/)

cy163 05-16-2009 08:01 AM

how to list the number of files in serveral sub-directories
 
Hello ALL,


I would like to learn how many files there are in respective sub-directories which are under a specified directory with one command.



Thanks

Disillusionist 05-16-2009 08:54 AM

Might be stretching the "one command" part, and I'm not entirely sure of what you are after, but how about:
Code:

echo "$(find . -type f|wc -l) files and $(find . -type d|wc -l) directories"

colucix 05-16-2009 11:29 AM

In one command is not so easy. If you don't restrict solution only to one-liners:
Code:

for dir in $(find . -mindepth 1 -type d)
do
  printf "%5d  %-40s\n" $(find $dir -maxdepth 1 -type f | wc -l) $dir
done



All times are GMT -5. The time now is 01:15 AM.