相关疑难解决方法(0)

从文本流中删除 ANSI 颜色代码

检查输出

perl -e 'use Term::ANSIColor; print color "white"; print "ABC\n"; print color "reset";'
Run Code Online (Sandbox Code Playgroud)

在文本编辑器(例如,vi)中显示以下内容:

^[[37mABC
^[[0m
Run Code Online (Sandbox Code Playgroud)

如何从输出文件中删除 ANSI 颜色代码?我想最好的方法是通过各种流编辑器来传输输出。

以下不起作用

perl -e 'use Term::ANSIColor; print color "white"; print "ABC\n"; print color "reset";' | perl -pe 's/\^\[\[37m//g' | perl -pe 's/\^\[\[0m//g'
Run Code Online (Sandbox Code Playgroud)

regex perl awk sed

116
推荐指数
8
解决办法
9万
查看次数

标签 统计

awk ×1

perl ×1

regex ×1

sed ×1