[SunHELP] total Number of Files in A Directory
TAMTONAX
abdulrashed.tamton at aramco.com
Mon May 1 05:58:27 CDT 2006
The below might be more easier and accurate if you want list only files:
ls -l|grep -v '^d'|wc -l (bash) without dir and without hidden files
^d means output starting with a d (dir)
grep -v (without printing whatever strings come after the -v)
ls -la|grep -v '^d'|wc -l (sh) without dir but with hidden files
Regards,
Rasheed Tamton
-----Original Message-----
From: sunhelp-bounces at sunhelp.org [mailto:sunhelp-bounces at sunhelp.org] On
Behalf Of Steve Sandau
Sent: Monday, May 01, 2006 1:42 PM
To: The SunHELP List
Subject: Re: [SunHELP] total Number of Files in A Directory
TAMTONAX wrote:
> Hello Saim,
>
> Solaris and AIX - both are different flavours - but still UNIX.
>
> ls -l|wc -l (calculate the no. of files in the current dir)
>
> ls -la|wc -l (calculate the no. of files in the current dir including
> hidden
> ones)
The way above is my standard method, too. If you need an exact count,
though, be aware that the -la option to ls will give you a count that
includes the current directory and the parent directory, so you need to
subtract two.
Steve
> ls -lR|wc -l (calculate the no. of files in the current dir and
> beneath - with subdirectories)
>
> ls -laR|wc -l (calculate the no. of files in the current dir and
> beneath including the hidden ones)
>
> find . -type f |wc -l (find all files and calculate the number
> including whatever files in the subdirectoris beneath)
>
> find . -type d|wc -l (find all dirs and calculate the number
> including whatever subdirectoris beneath)
>
> Just check the prune option with the find (man find) for more info.
>
> Regards,
> Rasheed Tamton.
>
> -----Original Message-----
> From: sunhelp-bounces at sunhelp.org [mailto:sunhelp-bounces at sunhelp.org]
> On Behalf Of Abrar, Saaim M.
> Sent: Monday, May 01, 2006 11:04 AM
> To: sunhelp at sunhelp.org
> Subject: [SunHELP] total Number of Files in A Directory
>
> Hello Gurus,
>
> How do we know total number of files in a directory on Solaris and AIX.
>
> Many Regards
>
> Saaim Abrar
> System Engineer
> Jeraisy Computers and Communications
> Oracle Certified 10G Professional
> Database Administrator
> Sun Solaris 8 Certified UNIX System Administrator Cellular
> 00966-508160132
_______________________________________________
SunHELP maillist - SunHELP at sunhelp.org
http://www.sunhelp.org/mailman/listinfo/sunhelp
More information about the SunHELP
mailing list