home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.unix.questions
- Path: sparky!uunet!paladin.american.edu!howland.reston.ans.net!zaphod.mps.ohio-state.edu!cs.utexas.edu!convex!convex!tchrist
- From: Tom Christiansen <tchrist@convex.COM>
- Subject: Re: How to total file sizes for selected files?
- Originator: tchrist@pixel.convex.com
- Sender: usenet@news.eng.convex.com (news access account)
- Message-ID: <1992Dec29.144421.23845@news.eng.convex.com>
- Date: Tue, 29 Dec 1992 14:44:21 GMT
- Reply-To: tchrist@convex.COM (Tom Christiansen)
- References: <103335@netnews.upenn.edu>
- Nntp-Posting-Host: pixel.convex.com
- Organization: Convex Computer Corporation, Colorado Springs, CO
- X-Disclaimer: This message was written by a user at CONVEX Computer
- Corp. The opinions expressed are those of the user and
- not necessarily those of CONVEX.
- Lines: 31
-
- From the keyboard of gasser@eniac.seas.upenn.edu (Nathan Gasser):
- :I'm wondering how to print the total size for only selected files.
- :For example, "du" gives the total space occupied by all files in
- :this directory. I want only those files, say, that end in .zip.
- :
- :% du
- :. 2883
- :
- :% du -s *.zip
- :123 file1.zip
- :188 arc2.zip
- :13 game.zip
- :
- :See, what I want is for the above example to print the total
- :space for the .zip files, ie. 324.
-
- Assuming find -ls output resembling this:
-
- (inum block mode links user group bytes mtime name)
- 38976 544 -rw-rw-r-- 1 tchrist swtools 531409 Dec 15 1989 ./etc/hosts
-
- This command works fine:
-
- find . -name '*.zip' -ls | awk '{s += $2} END {print s}'
-
- --tom
- --
- Tom Christiansen tchrist@convex.com convex!tchrist
- No, I had no problem communicating with Latin American heads of state -
- though now I do wish I had paid more attention to Latin when I was in
- high school. --Vice President Dan Quayle
-