Can ls show total Kbytes of "foo*"?

Brian V. Smith envbvs at epb2.lbl.gov
Sat Oct 28 07:28:04 AEST 1989


In article <1989Oct27.130914.12943 at world.std.com>, madd at world.std.com
(jim frost) writes:
< In article <2453 at umbc3.UMBC.EDU> rostamia at umbc3.UMBC.EDU (Rouben
Rostamian) writes:
< |
< |I wonder if there is an obvious way to compute the total size of all
< |"foo*" files in a directory.  The only way I know how is the ridiculously 
< |complicated construction:
< |
< |ls -1s foo* | awk 'BEGIN{size=0} {size += $1} END{print "total: " size}'
< [...]
< |Am I missing something obvious?
< 
< Yes.  You could just do "wc -c foo* | tail -1".  If you don't do the
< tail it will display the size of each followed by a summary line; with
< it you get just the summary line or -- if there's only one file --
< just the size.

Try that on some LARGE files and you will quickly (slowly) see that
"wc" is much slower than the "ls."
_____________________________________
Brian V. Smith    (bvsmith at lbl.gov)
Lawrence Berkeley Laboratory
I don't speak for LBL, these non-opinions are all mine.



More information about the Comp.unix.questions mailing list