[SunHELP] total Number of Files in A Directory

Phil Stracchino phil.stracchino at speakeasy.net
Mon May 1 07:19:36 CDT 2006


Abrar, Saaim M. wrote:
> Hello Gurus,
> 
> How do we know total number of files in a directory on Solaris and AIX.

1.  To find the total number of file and directory entries in the
directory foo, use ls:

ls -ld foo
note the link count, subtract 2.


2.  To find the total number of files and directories in the directory
foo and its subdirectories, use find:

find foo/ -type f | wc -l		to count files
find foo/ -type d | wc -l		to count subdirectories
find foo/ -print | wc -l		to count everything

See man find for more information.


3.  To post to sunhelp, please don't forward or quote the entire digest
message you last received.  It doesn't help anyone to answer your
question, wastes bandwidth and resources, and annoys people.



-- 
 Phil Stracchino                     Landline: 603-886-3518
 phil.stracchino at speakeasy.net         Mobile: 603-216-7037
 Renaissance Man, Unix generalist, Perl hacker, Free Stater



More information about the SunHELP mailing list