小编iam*_*ton的帖子

如何从标准输出和管道中去除颜色代码到文件和标准输出

我有一个程序,使用printf一些tput在它混合,我想管道输出到stdout和文件。我更喜欢使用,sed因为我不希望对我的脚本有任何不必要的依赖。这是我到目前为止所得到的。

printf "\n$(tput setaf 6)| $(tput sgr0)$(tput setaf 7)Sourcing files...\033[m\n" | tee install.log

唯一的问题是我的日志文件正在获取所有颜色输出...

^[[36m| ^[(B^[[m^[[37mSourcing files...^[[m

我希望它只是有 | Sourcing files...

bash shell-script bash-script

16
推荐指数
1
解决办法
2万
查看次数

标签 统计

bash ×1

bash-script ×1

shell-script ×1