sh - Unix-- get 3rd field sum from a file -
i have file 5 fields 10 rows of data, want sum of 3rd fields in file.
sample:
a,b,1,4,5 c,d,3,4,6 f,h,4,y,j o/p: 1+3+4= 8
my solution cut 3rd field using cut command , write file , using awk calculate sum.
is there alternative way?
i think need:
awk -f, '{ sum += $3 } end {print sum}' filename
Comments
Post a Comment