home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / unix / question / 15016 < prev    next >
Encoding:
Text File  |  1992-12-29  |  1.8 KB  |  49 lines

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