awk:在源代码行1上进行救援 [英] awk: bailing out at source line 1

查看:129
本文介绍了awk:在源代码行1上进行救援的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望获得一些彩色的日志输出,并且不想使用multitail.

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

我要执行的命令是:

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

但是我遇到了错误:

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

我的完全非专家的猜测是,由于某种原因,它认为终端代码应在其上加上]'s.我已经尝试将它们转义,但这是行不通的,并且坦率地说,我不确定这不会增加终端代码.

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.

推荐答案

安装并切换到gawk可以解决此问题.感谢所有有帮助的答复.

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

这篇关于awk:在源代码行1上进行救援的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆