Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Click here to return to the 'How about a file count' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
How about a file count
Authored by: pierrot-lunaire on Mar 01, '03 06:10:41AM

There are many ways for this. The two I use regularly are:

ls <folder> | wc -l
quick 'n dirty, gives the number of objects (files, folders, links..), no
recursion, no .files.

If you want recursion OR if you want to distinguish files from folders OR
if you want to include .files, use find:

find <folder> -type f -maxdepth 1 | wc -l

this is for files only, includes .files.
Use -type d for directories only, remove -maxdepth 1 to find all files/
folders recursively, remove -type argument to find everything (like ls

Use man wc to find information on wc (probably coming from 'word
count' - the -l options counts lines.

[ Reply to This | # ]