[TriLUG] file and directory count

Ken Mink kmtrilug at nc.rr.com
Fri Aug 1 11:10:08 EDT 2003


Another big problem with doing it with 'ls' is that it won't get dot
files. If you don't get the dot files in /home, your count will be WAY
off. If you use 'ls -a', you'll get '.' and '..'. You'll have to
remember to subtract 2 from the count.
The find command is the way to go.

Ken


On Fri, 2003-08-01 at 09:45, Dan Monjar wrote:
> --On Thursday, July 31, 2003 04:36:07 PM -0400 Tanner Lovelace 
> <lovelace at wayfarer.org> wrote:
> 
> > ls -1 | wc -l
> >
> > By using -1 instead of -l (that's a one instead of a letter l) it
> > does not put the non-file line at the top (at least that I know of)
> > so it will give you a count of all the files in the current directory
> > only.
> 
> To be obsessively nit-picky, you don't need the '-1' just
> 
> 	ls|wc -l
> 
> will do it.  When the output of 'ls' is not a terminal, as in a pipe, then 
> the '-1' is the default.
> 
> --
> Daniel Monjar
> IS Manager, Technical Services
> bioMérieux, Inc.
> Durham, NC US
-- 
"They that can give up essential liberty to obtain a little temporary
safety deserve neither liberty nor safety."--Benjamin Franklin
" 'Necessity' is the plea for every infringement of human liberty; it
is the argument of tyrants; it is the creed of slaves."--William Pitt 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
URL: <http://www.trilug.org/pipermail/trilug/attachments/20030801/c5a8ce3f/attachment.pgp>


More information about the TriLUG mailing list