macosawkterminal-color

awk: bailing out at source line 1


I'm looking to get some colorized log output and don't want to use multitail.

The command I'm trying to execute is:

tail -100f some_file.log | awk '/INFO/ {print "\033[32m" $0 "\033[39m"} /Exception/ {print "\033[31m" $0"\033[39m"}'

but I'm getting the error:

awk: syntax error at source line 1
 context is
     >>> /INFO <<< / {print "\033[32m" $0 "\033[39m"} /Exception/ {print "\033[31m" $0"\033[39m"}
    4 missing ]'s
awk: bailing out at source line 1

My totally non-expert guess is that for some reason it thinks the terminal codes should have closing ]'s on them. I've tried escaping them but that doesn't work and frankly, I'm not sure that this wouldn't jack up the terminal codes.


Solution

  • Installing and switching to gawk fixed the issue. Thanks to everyone who had helpful replies.