data.txt:
price: 1
price: 3
price: 5
price: 7
price: 9
# cat data.txt | awk -F'\t' '{s = s +$2} {print s} END{print "sum: " s}'
1
4
9
16
25
sum: 25
-F'\t' : use tab as a separator
The Unix Programming Environment P.118
Wednesday, December 7, 2011
Subscribe to:
Post Comments (Atom)
1 comment:
Nice Article.
Some examples on Find Command and Awk Command
Post a Comment