Xref: utzoo comp.unix.questions:29664 comp.unix.shell:1727 Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!magnus.acs.ohio-state.edu!tut.cis.ohio-state.edu!dsac.dla.mil!ddtc.dla.mil!marst2!vwa0201 From: vwa0201@marst2 (Larry Baca) Newsgroups: comp.unix.questions,comp.unix.shell Subject: CAN AWK KEEP COUNT Message-ID: <356@marst2> Date: 21 Mar 91 22:04:10 GMT Followup-To: comp.unix.questions Organization: Defense Automatic Addressing Systems Office, Dayton Ohio 45444 Lines: 24 In one portion of a script I have written (csh), I need to keep a running total of certain fields within a record found by grep. My grep statement looks something like this: grep $pattern $infile | tee $outfile | cut -c49-100 | awk ...... My problem is in awk, I want to feed "awk" cols 49-100 of the greped record. The "cut" record consists of 5 numeric fields of 10, 12, 10, 10, and 10 cols in length, no spaces. I want awk to keep a running total for each field and spit the grand totals out at the end. As you can see I am also writing the entire record to $outfile. I would also like "awk" to make the grand totals available to the rest of the script. I might add the file I am working with is around 900K 100 col rcds, so maybe awk isn't the way to go. -- /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ LARRY BACA, marst2!lbaca DAASO-VWA AIS, DEFENSE AUTOMATIC ADDRESSING OFFICE, WESTERN DIVISION DDTC TRACY, TRACY CA. 95376-5057 AUTOVON 462-9391 COMERCIAL 832-9391