Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Counting number of files into a directory

Status
Not open for further replies.

cadbilbao

Programmer
Apr 9, 2001
233
ES
Hi!

I do not remember the way to count the number of files and subfolders stored into the same directory.

Could anybody help me?
 
You can always do "ls -l |wc -l"

This will give you a long list of the dir, and then
count the lines.

Cheers
 
I'd use find :-

cd directory
find . -print | wc -l


If you just want to count files (not directories), then

find . -type f -print | wc -l

For Directories only,

If you just want to count files (not directories), then

find . -type d -print | wc -l

HTH TandA
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top