Link to home
Start Free TrialLog in
Avatar of FireBall
FireBall

asked on

Awk error

in some rows of tcp dump out put with awk

tcpdump -nnlq -v -X udp  | awk '/ IP /{gsub("[,)]","");ttl=$6;proto=$14;leng=$17;}/ > /{gsub(/:/,"");a=$1;b=$3;}/0x0020:/{n=split(a,s,/[.]/);sub("[.]" s[n] "$"," " s[n],a);n=split(b,s,/[.]/);sub("[.]" s[n] "$"," " s[n],b);$1="";$NF="";gsub(" ..","& ");print a, b, proto,leng,ttl,$0 }'

we got the following error is there any way to prevent it

awk: (FILENAME=- FNR=3510) fatal: Unmatched ( or \(: /[.](hlim$/

Open in new window

Avatar of ozo
ozo
Flag of United States of America image

awk '/ IP /{gsub("[,()]","");ttl=$6;proto=$14;leng=$17;}/ > /{gsub(/:/,"");a=$1 " " $3 " ";gsub(/[^.]+ /," & ",a);}/0x0020:/{gsub(/[^.]+$/," &",a);gsub(/[^.]+$/," &",b);$1="";$NF="";gsub(" ..","& ");print a, b, proto,leng,ttl,$0 }'
Avatar of FireBall
FireBall

ASKER

Solved but it puts a dot to the end of ip addresses


178.20.225.235. 54513  255.255.255.255.  48887    UDP 75 128  05 00 00 00 00 00 00 00 f8 be 00 00 13 00 00 00
178.20.225.235. 54513  255.255.255.255.  48887    UDP 75 128  05 00 00 00 00 00 00 00 f8 be 00 00 13 00 00 00
178.20.225.235. 54513  255.255.255.255.  48887    UDP 75 128  05 00 00 00 00 00 00 00 f8 be 00 00 13 00 00 00
37.123.103.5. 137  37.123.103.15.  137    UDP 78 128  00 01 00 00 00 00 00 00 20 46 48 46 41 45 42 45
178.20.225.235. 54513  255.255.255.255.  48887    UDP 75 128  05 00 00 00 00 00 00 00 f8 be 00 00 13 00 00 00
37.123.102.245. 137  37.123.102.255.  137    UDP 78 128  00 01 00 00 00 00 00 00 20 46 48 46 41 45 42 45
178.20.225.235. 54513  255.255.255.255.  48887    UDP 75 128  05 00 00 00 00 00 00 00 f8 be 00 00 13 00 00 00
37.123.98.230. 137  37.123.98.255.  137    UDP 78 128  00 01 00 00 00 00 00 00 20 46 48 46 41 45 42 45
37.123.96.154. 137  37.123.96.159.  137    UDP 78 128  00 01 00 00 00 00 00 00 20 46 48 46 41 45 42 45
178.20.225.235. 54513  255.255.255.255.  48887    UDP 75 128  05 00 00 00 00 00 00 00 f8 be 00 00 13 00 00 00
178.20.225.235. 54513  255.255.255.255.  48887    UDP 75 128  05 00 00 00 00 00 00 00 f8 be 00 00 13 00 00 00
178.20.225.235. 54513  255.255.255.255.  48887    UDP 75 128  05 00 00 00 00 00 00 00 f8 be 00 00 13 00 00 00
37.123.103.20. 137  37.123.103.31.  137    UDP 78 128  00 01 00 00 00 00 00 00 20 45 4e 45 50 45 4f 45
178.20.225.235. 54513  255.255.255.255.  48887    UDP 75 128  05 00 00 00 00 00 00 00 f8 be 00 00 13 00 00 00

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of ozo
ozo
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial