Programming: September 2007 Archives

Some tips about awk

user-pic
Vote 0 Votes

Get the sum of single column
cat a.txt
26.2578125
126.023438
705.6875
6000
7849.08594
15260
35243.3125
88700
378483
Usage: cat a.txt|awk '{(tot+=$1)};END{ print tot}'

Get the sum of each column
cat b.txt
111781888     2564208
111781888     21437296
39077120      21338848
111781888     3138160
111781888     17370216
111781888     9237336
111781888     3484016
111781888     3068568
Usage: cat b.txt| awk '{(tot+=$1) (tot2+=$2)};END{print tot, tot2}'

About this Archive

This page is an archive of entries in the Programming category from September 2007.

Find recent content on the main index or look in the archives to find all content.