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

  1. Newsgroups: comp.unix.questions
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!usc!howland.reston.ans.net!bogus.sura.net!darwin.sura.net!Sirius.dfn.de!news.DKRZ-Hamburg.DE!regen.DKRZ-Hamburg.DE!m212022
  3. From: m212022@regen.DKRZ-Hamburg.DE (Wolfgang Welke)
  4. Subject: Re: How to total file sizes for selected files?
  5. Message-ID: <1992Dec30.184600.720@news.DKRZ-Hamburg.DE>
  6. Sender: news@news.DKRZ-Hamburg.DE
  7. Organization: Deutsches Klimarechenzentrum GmbH, Hamburg
  8. References: <103335@netnews.upenn.edu> <1992Dec29.144421.23845@news.eng.convex.com> <1992Dec30.083126.26511@ptsfa.PacBell.COM>
  9. Date: Wed, 30 Dec 92 18:46:00 GMT
  10. Lines: 43
  11.  
  12. In article <1992Dec30.083126.26511@ptsfa.PacBell.COM> dmturne@PacBell.COM (Dave Turner) writes:
  13. >From the keyboard of gasser@eniac.seas.upenn.edu (Nathan Gasser):
  14. >:I'm wondering how to print the total size for only selected files.
  15. >:For example, "du" gives the total space occupied by all files in
  16. >:this directory.  I want only those files, say, that end in .zip.
  17. >:
  18. >:% du
  19. >:. 2883
  20. >:
  21. >:% du -s *.zip
  22. >:123  file1.zip
  23. >:188  arc2.zip
  24. >:13   game.zip
  25. >:
  26. >:See, what I want is for the above example to print the total
  27. >:space for the .zip files, ie. 324.
  28. >
  29. >Assuming find -ls output resembling this:
  30. >
  31. >(inum  block mode      links  user  group      bytes  mtime        name)
  32. > 38976  544 -rw-rw-r--  1 tchrist  swtools    531409 Dec 15  1989 ./etc/hosts
  33. >
  34. >You might try wc:
  35. >
  36. >    wc -c *.zip | sed -n '$p'
  37. >-- 
  38. >Dave Turner    (510) 823-2001    {att,bellcore,sun,ames,decwrl}!pacbell!dmturne
  39.  
  40. There are reasons not to use 'wc':
  41. Files are read by wc, whereas du uses directory information.
  42. On systems with some data migration facility it's even worse,
  43. because wc causes files to be reloaded from the backup system
  44. (i.e. tapes).
  45. If du wants to summarize directories, why not give it one?
  46.  
  47.    mkdir temporary
  48.    ln *.zip temporary
  49.    du temporary
  50.    rm temporary/*
  51.    du temporary
  52.  
  53. The second du gives the size of the directory without files
  54. (usually one, if there are not too many *.zip files)
  55.