Operating System - HP-UX
1756805 Members
2845 Online
108852 Solutions
New Discussion юеВ

Re: totalling columns in a script

 
SOLVED
Go to solution
Robin Wakefield
Honored Contributor

Re: totalling columns in a script

Well here's one way:

perl -ape '{$a+=$F[4];$b+=$F[5];$c+=$F[6]}END{printf("Total %50d %8d %8d\n",$a,$b,$c)}' yourfile

rgds, Robin
Mike Miller_8
Regular Advisor

Re: totalling columns in a script

simply run the awk program provided using the command

awk -f file.awk filename > outputFile

I think this will generate what you want.

= Mike =

miracle
Frequent Advisor

Re: totalling columns in a script

Thanks Robin for the perl script, that too works well. Thanks Mike for your script as well, but I was trying to limit the padding for the spaces. This case is closed.