Welcome to WebmasterWorld Guest from 54.167.46.29

Forum Moderators: bakedjake

Message Too Old, No Replies

Count files

In root and subdirectories.

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

Preferred Member

10+ Year Member

joined:Sept 7, 2003
posts:383
votes: 0


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 July 31, 2006 (gmt 0)

Senior Member from KZ 

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

joined:Jan 10, 2005
posts:2886
votes: 1


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 July 31, 2006 (gmt 0)

New User

10+ Year Member

joined:June 7, 2005
posts:6
votes: 0


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 July 31, 2006 (gmt 0)

Preferred Member

10+ Year Member

joined:Sept 7, 2003
posts:383
votes: 0


Thanks Lammert

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

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

Preferred Member

10+ Year Member

joined:Sept 7, 2003
posts:383
votes: 0


Thank you modean987

That done the trick