CAN AWK KEEP COUNT

Larry Baca vwa0201 at marst2
Fri Mar 22 08:04:10 AEST 1991


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



More information about the Comp.unix.shell mailing list