home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / unix / question / 10201 < prev    next >
Encoding:
Internet Message Format  |  1992-08-19  |  820 b 

  1. Path: sparky!uunet!usc!news
  2. From: rpinder@phad.hsc.usc.edu (Rich Pinder)
  3. Newsgroups: comp.unix.questions
  4. Subject: Simple AWK question.....
  5. Date: 19 Aug 1992 23:45:08 -0700
  6. Organization: University of Southern California, Los Angeles, CA
  7. Lines: 21
  8. Sender: rpinder@phad.hsc.usc.edu (Rich Pinder)
  9. Distribution: world
  10. Message-ID: <l96frkINNsom@phad.hsc.usc.edu>
  11. NNTP-Posting-Host: phad.hsc.usc.edu
  12.  
  13. I'd like to reference the environment variable PWD inside an awk script.  I
  14. wrote the following simple script to sum bytes in any given directory, and
  15. would like the output to say:  Total Bytes in /usr/lib: 1024000 (1 MB).
  16.  
  17. Thanks for you help
  18.  
  19.  
  20. ......................
  21.  
  22. #    sums directory bytes (BSD)
  23.  
  24. ls -l | awk  '
  25.  
  26.         {sum += $4}
  27.  
  28.     END    {printf "Total Bytes in Directory:  %10d   (%7.1f  MB)\n", sum, sum/1024000}
  29.  
  30. -- 
  31.  
  32.  
  33. Rich
  34.