i have 8000 lines similar to this
and what i need to do is summing rxPackets in each line together and txPackets too
i mean total sum of them in 8000 lines
thanks in advance
Answer
You can use this small awk script for GNU awk:
awk 'BEGIN {x=0;y=0} { match($13,/([0-9]+)/,a); x = x + a[1]; match($12,/([0-9]+)/,b); y = y + b[1]} END {print "rxPackets:" x " txPackets:" y}' yourfile
No comments:
Post a Comment