Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!uunet!ittc!fpb From: fpb@ittc.wec.com (Frank P. Bresz) Newsgroups: comp.unix.questions Subject: addcol - # [Was: Re: What's wrong with this Bourne shell script?] Message-ID: Date: 16 Aug 90 20:19:19 GMT References: <1990Aug6.172225.20319@iwarp.intel.com> <850@jonlab.UUCP> <416@necssd.NEC.COM> Sender: news@ittc.wec.com Reply-To: fbresz@ittc.wec.com Organization: Westinghouse, ITTC, Pgh, PA. Lines: 24 In-reply-to: harrison@necssd.NEC.COM's message of 15 Aug 90 18:36:10 GMT In article <416@necssd.NEC.COM> harrison@necssd.NEC.COM (Mark Harrison) writes: >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! It is EXACTLY what I was looking for. Thank you very much for weeding through and figuring out what I really wanted.!! -- +--------------------+ |fbresz@ittc.wec.com | My opinions are my own, I'm not paid |uunet!ittc!fbresz | enough to make an official statement |(412)733-6749 | +-----------------------------------+ |Fax: (412)733-6444 | | THIS SPACE FOR SALE!!! | +--------------------+ +-----------------------------------+