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

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -