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

FireBallITAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ozoCommented:
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 }'
FireBallITAuthor Commented:
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

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
FireBallITAuthor Commented:
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.