home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.unix.questions
- Path: sparky!uunet!magna!doc
- From: doc@magna.com (Matthew J. D'Errico)
- Subject: Re: Simple AWK question.....
- Message-ID: <BtAAI4.1AD@magna.com>
- Organization: Magna Software Corporation
- References: <l96frkINNsom@phad.hsc.usc.edu>
- Date: Thu, 20 Aug 1992 13:22:51 GMT
- Lines: 32
-
- In article <l96frkINNsom@phad.hsc.usc.edu> you write:
- >I'd like to reference the environment variable PWD inside an awk script. I
- >wrote the following simple script to sum bytes in any given directory, and
- >would like the output to say: Total Bytes in /usr/lib: 1024000 (1 MB).
- > [...]
- >......................
- >
- ># sums directory bytes (BSD)
- >
- >ls -l | awk '
-
- WrkDir = "'$PWD'"
- >
- > {sum += $4}
- >
- > END {printf "Total Bytes in Directory: %10d (%7.1f MB)\n", sum, sum/1024000}
-
- END {printf "Total Bytes in $WrkDir: %10d (%7.1f MB)\n", sum, sum/1024000}
-
- -----------------------------
- Give that a try...
-
- -- Doc
- +-------------------------------+---------------------------------------+
- | Matthew J. D'Errico | DOMAIN: mderrico@magna.com |
- | Magna Software Corporation | uucp: uunet!magna!mderrico |
- | 275 Seventh Avenue | CompuServe: 70744,3405 |
- | 20th Floor +---------------------------------------+
- | New York, NY 10001 | Voice : 212 / 727 - 6737 |
- | USA | Fax : 212 / 691 - 1968 |
- +-------------------------------+---------------------------------------+
-
-