Can ls show total Kbytes of "foo*"?

jim frost madd at world.std.com
Fri Oct 27 23:09:14 AEST 1989


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.

jim frost
software tool & die     "The World" Public Access Unix for the '90s
madd at std.com            +1 617-739-WRLD  24hrs {3,12,24}00bps



More information about the Comp.unix.questions mailing list