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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Count files in directory?

Status
Not open for further replies.

datadan

IS-IT--Management
Joined
Jul 22, 2002
Messages
283
Location
US
How do I count the number of files in a directory?

Any counting Recurrsively?

THanks,
 
ls | wc -l

recursively:

ls -R | grep -v -e / -e '^$' | wc -l

 
Just because everyone has to respond to shell-related stuff ;-)
[tt]
find . -type f -print -maxdepth 1 | wc -l
[/tt]

----
JBR
 

Flugh is right and to do it recursively, drop the -maxdepth 1
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top