Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How sort values by column in some file using awk? 1

Status
Not open for further replies.

eksarajavo

Technical User
Oct 21, 2006
2
BA
Hi people,
I have file a.txt with content
2 3
2 4
5 6

how write a script in awk to sort values by column to get result like
9 13.
I tried some solutins but without success.
Any help is welcome.
Regards
 
You meant add instead of sort ?
awk '{t1+=$1;t2+=$2}END{print t1,t2}' a.txt

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thank you very much that is exactlly what I look for.

Thank you again

Regards
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top