使用sed为标签添加背景色? [英] Use sed to add background color to tabs?
本文介绍了使用sed为标签添加背景色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以使用sed更改标签(或其他任何文本)的背景颜色,例如,我可以运行以下内容?
Is possible to use sed to change the background color of tabs (or any other text), so that, for example, I could run something like the following?
somefunction | sed -e 's/(some pattern)/(set bg color)\1(unset bg color)/g'
推荐答案
是:
#!/bin/bash
norm_bg=$(tput sgr0)
red_bg=$(tput setab 1)
echo -e "foo\tbar\tbaz" | sed "s/\t/$red_bg $norm_bg/g"
See this link for other Color Codes (very bottom)
这篇关于使用sed为标签添加背景色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文