Xref: utzoo comp.unix.ultrix:2050 comp.unix.questions:17240 Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!hellgate.utah.edu!helios.ee.lbl.gov!epb2.lbl.gov!envbvs From: envbvs@epb2.lbl.gov (Brian V. Smith) Newsgroups: comp.unix.ultrix,comp.unix.questions Subject: Re: Can ls show total Kbytes of "foo*"? Message-ID: <4039@helios.ee.lbl.gov> Date: 27 Oct 89 21:28:04 GMT References: <1989Oct27.130914.12943@world.std.com> <2453@umbc3.UMBC.EDU> Sender: usenet@helios.ee.lbl.gov Reply-To: envbvs@epb2.lbl.gov (Brian V. Smith) Organization: Lawrence Berkeley Laboratory Lines: 24 In article <1989Oct27.130914.12943@world.std.com>, madd@world.std.com (jim frost) writes: < In article <2453@umbc3.UMBC.EDU> rostamia@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@lbl.gov) Lawrence Berkeley Laboratory I don't speak for LBL, these non-opinions are all mine.