Welcome to WebmasterWorld Guest from

Forum Moderators: bakedjake

Message Too Old, No Replies

Count files

In root and subdirectories.



4:10 pm on Jul 31, 2006 (gmt 0)

10+ Year Member

I have a directory called CMS and under that directory I have multiple subdirctories each containing files. I need to count the files in the CMS directory and all of it's subdirectories. I usually acomplish this by downloading CMS to my Windows PC and using windows tools to do a file count, however this directory is now getting very large and this is a time consuming process.

Can anybody help me out with a UNIX command that will do the same?

I don't want a count of the directories just the files.

Any help would be much appreciated.


5:50 pm on Jul 31, 2006 (gmt 0)

WebmasterWorld Senior Member lammert is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

Something like "ls -R ¦ wc" will do. This performs a recursive directory listing. The output is piped to wc, a utility that counts the number of words and lines.


7:32 pm on Jul 31, 2006 (gmt 0)

10+ Year Member

If all you want is a total file count

find . -type f wc -l

find [period] [dash]type f [pipe] wc [dash][el]

If you copy/paste this line into a linux command prompt, make sure the pipe symbol is a solid vertical line (not the broken vertical line webmasterworld changes it to when trying to post this message).


7:37 pm on Jul 31, 2006 (gmt 0)

10+ Year Member

Thanks Lammert

But I'm a complete *nix novice, so I'm looking for the exact command.


7:40 pm on Jul 31, 2006 (gmt 0)

10+ Year Member

Thank you modean987

That done the trick


Featured Threads

Hot Threads This Week

Hot Threads This Month