1
i cant run this code because of an error
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
the problem is ",a" and ",b" that put numbers in array a
input is some lines like this:
<Flow flowId="1" timeFirstTxPacket="+0.0ns" timeFirstRxPacket="+924100.0ns" timeLastTxPacket="+199984927558.0ns" timeLastRxPacket="+199675473275.0ns" delaySum="+2287566662167.0ns" jitterSum="+65280162191.0ns" lastDelay="+3511349483.0ns" txBytes="161956" rxBytes="116536" txPackets="3125" rxPackets="2251" lostPackets="640" timesForwarded="0">
and output will get me sum of rxPackets and txPackets seperatly in for example 100 lines but it will give me error
i need to do this in any way possible thanks
I suggest bailing out before writing one more line of AWK and use a modern scripting language such as Python. – kmarsh – 2013-12-12T14:54:12.520
What error are you getting? Are you certain that all lines are formatted correctly? Are you using GNU awk, or a different one (if you don't know: are you runing this on Linux (what distribution? embeddable ones are different), cygwin, or something else? – Gabe – 2013-12-12T15:06:57.230
@Gabe ubuntu 13.04 MAWK(1) – Arash – 2013-12-12T15:07:41.660
... and again, what is the error you're seeing? I do not understand what you mean with "the problem is ",a" and ",b" that put numbers in array a". – Gabe – 2013-12-12T15:12:49.527
Please see my revised post. – MariusMatutiae – 2013-12-12T15:18:05.403
Please post one question about the problem you're trying to solve – this is something you should've edited your old question with and talked about with the user who answered, if the syntax didn't work. – slhck – 2013-12-12T15:35:04.130