Number of files in a directory?

Master Vampire spotter at eve.wright.edu
Tue May 21 14:28:58 AEST 1991


In article <116 at kaspar.UUCP> ires at kaspar.UUCP (Bruce R Larson) writes:
>>mikeh at fsd.cpsc.ucalgary.ca (Michael Hoffos) writes:
>>>... how can you get the number of files that are in a directory?
>In article < ... > cpcahil at virtech.uucp (Conor P. Cahill) writes:
>>The following will always work:
>>	for a single directory:		ls -a | wc -l
>Because so many of us alias `ls' to things like `ls -xF' it's a good
>idea to issue a full path name to `ls' in the command above.
>	/bin/ls -a | wc -l
>Don't forget that `.' and `..' are being counted.

Well, to correct for '.' and '..', you can use 

	/bin/ls -A | wc -l 

Or, at least, I assume '-A' will work on most system.  It is supposed to list
every file, except '.' and '..'  

Steve

--
anagram at desire.wright.edu | "Role becomes the actor, she's addicted to applause
spotter at eve.wright.edu    |  The stage a world because she never leaves it."
			  |  -Rush
<Std.Dsc> WSU doesn't approve of anything I do, but that hasn't stopped me yet.



More information about the Comp.unix.questions mailing list