Newsgroups: comp.unix.questions Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!think.com!snorkelwacker.mit.edu!bloom-picayune.mit.edu!athena.mit.edu!jik From: jik@athena.mit.edu (Jonathan I. Kamens) Subject: Re: CAN AWK KEEP COUNT Message-ID: <1991Mar22.115457.1668@athena.mit.edu> Sender: news@athena.mit.edu (News system) Organization: Massachusetts Institute of Technology References: <356@marst2> Date: Fri, 22 Mar 91 11:54:57 GMT Lines: 29 First of all, you don't have to use cut to pass awk the 49th through 100th columns of the data; awk can figure out what to use itself. Second, awk is capable of both splitting strings at specified columns (using substr) and of keeping a running total. Something like this: awk 'BEGIN { column1 = column2 = column3 = column4 = column5 = 0; } { column1 += substr($0,49,10); column2 += substr($0,59,12); column3 += substr($0,71,10); column4 += substr($0,81,10); column5 += substr($0,91,10); } END { printf("%d %d %d %d %d\n", column1, column2, column3, column4, column5); }' -- Jonathan Kamens USnail: MIT Project Athena 11 Ashford Terrace jik@Athena.MIT.EDU Allston, MA 02134 Office: 617-253-8085 Home: 617-782-0710 P.S. By the way, both substr and the math capabilities of awk are among its basic functions that are documented in the man page. If you needed to ask on the net about them, I think perhaps you need to do a little bit more documentation reading.