[SunHELP] Fwd: total Number of Files in A Directory

RichT (list addr) lmail at catsnest.co.uk
Thu May 4 11:37:50 CDT 2006


> How do we know total number of files in a directory on Solaris and AIX.


> ls -l|wc -l

>ls -l|grep -v '^d'|wc -l

well at least on one of my Sol boxes (5.8)

`ls -l ` outputs like this

# ls -l
total 6
-rw------- 2 owner group date filename

so wc -l ing that would give 2 (as it includes the total filesize line)

so i hacked together the above like this...

echo $((`ls -al | grep -v ^d | wc -l` -1))

of course you can change it to sute you situation ie hidden files directorys


<-- http://23.me.uk --> <-- http://info-x.co.uk  --> <--
http://wiki.s23.org--> <-- Get FireFox Now -->
<- Engineers believe that if it ain't broke, it doesn't have enough features
yet. - JG Burns ->

More information about the SunHELP mailing list