Better if you remove que hash table: BEGIN { FS = "\t+" OFS= "\t" } $2 ~ /[0-9]+\.?[0-9]*/ { car += $2 pro += $3 fat += $4 } END{ print "Totals", car, pro, fat }
On Sat, May 2, 2009 at 8:36 AM, Amit Uttamchandani <atu13...@csun.edu> wrote: > On Sat, 2 May 2009 00:00:15 +0200 > pmarin <pacog...@gmail.com> wrote: > >> Do you want to calculate only the total? >> Use hard tabs "\t" to separate columns >> >> My version: >> >> BEGIN { >> FS = "\t+" >> OFS= "\t" >> } >> $2 ~ /[0-9]+\.?[0-9]*/ { >> total["car"] += $2 >> total["pro"] += $3 >> total["fat"] += $4 >> } >> END{ >> print "Totals", total["car"], total["pro"], total["fat"] >> > > Thanks! I think this will do the trick. > >