bash - Errors when executing switch/case in awk command in Ubuntu and Mac -


i have strange problem when executing following code:

awk '{ foo = 1; switch (foo) { case 1: i=i+1; break; } }' ./tcpheader.txt 

getting following error:

awk: syntax error @ source line 1  context     { foo = 1; switch (foo) >>>  { <<<  awk: illegal statement @ source line 1 awk: illegal statement @ source line 1 

any idea what's problem ?

tested on mac:

awk --version 

output:

awk version 20070501 

tested on ubuntu:

awk -w version 

output:

mawk 1.3.3 nov 1996, copyright (c) michael d. brennan  compiled limits: max nf             32767 sprintf buffer      2040 

installing gawk solved problem:

sudo apt-get install gawk 

in mac:

sudo port install gawk 

Comments

Popular posts from this blog

timeout - Handshake_timeout on RabbitMQ using python and pika from remote vm -

gcc - MinGW's ld cannot perform PE operations on non PE output file -

c# - Search and Add Comment with OpenXML for Word -