View Single Post
  #1   (View Single Post)  
Old 29th April 2011
sharris sharris is offline
Package Pilot
 
Join Date: Jun 2010
Posts: 146
Default How-To get a directory count

Hello everybody!

I did a search and finally found out how to get the file count in various ways with-in a direcory. These works very well on FreeBSD current-9.0:

Code:
 ls | wc -l  #  count files and one for each directories in the current (target) directory.

find /target/directory -type f -print | wc -l    # count all files in all directories, but exclude directories count

find /target/directory -maxdepth 1 -type f -print | wc -    #  all files, in given directory only.
... but I found nothing about how-to get a count of directories only with-in a directory.

My questions is:

1) How do we get the count of all directories only with-in a directory.

2) and than how to get a list of all directory names with-in a given directory.

Thanks in advance
Reply With Quote