Path: utzoo!utgpu!news-server.csri.toronto.edu!clyde.concordia.ca!uunet!snorkelwacker!spdcc!mirror!necntc!necssd!harrison From: harrison@necssd.NEC.COM (Mark Harrison) Newsgroups: comp.unix.questions Subject: Re: What's wrong with this Bourne shell script? Message-ID: <416@necssd.NEC.COM> Date: 15 Aug 90 18:36:10 GMT References: <1990Aug6.172225.20319@iwarp.intel.com> <850@jonlab.UUCP> Organization: NEC America Inc. SSD, Irving, TX Lines: 26 In article , fpb@ittc.wec.com (Frank P. Bresz) writes: > Where is Jon's addcol. I tried to write one a while back and kept > screwing it up. I would like to see a working version. Here is a simple one in awk. Replace $4 with your column number. awk '{ tot += $4} END{print tot}' ^^ If you put this into a shell script called addcol, you can say awk '{ tot += $'$1'} END{print tot}' and invoke it by addcol 4 Example: How many bytes in my files? ls -l c* | awk '{ tot += $4} END{print tot}' ls -l c* | addcol 4 Hope this helps! -- Mark Harrison harrison@necssd.NEC.COM (214)518-5050 {necntc, cs.utexas.edu}!necssd!harrison standard disclaimers apply...