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

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -