可以彩色输出通过shell重定向被捕获? [英] Can colorized output be captured via shell redirect?

查看:183
本文介绍了可以彩色输出通过shell重定向被捕获?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用各种庆典命令 - 花哨的diff,建立脚本等,产生大量的彩色输出

Various bash commands I use -- fancy diffs, build scripts, etc, produce lots of color output.

当我将此输出重定向到一个文件,然后文件后,彩色化走了 - presumably b / C输出重定向行为剥离出来的颜色codeS,告诉终端改变颜色

When I redirect this output to a file, and then cat or less the file later, the colorization is gone -- presumably b/c the act of redirecting the output stripped out the color codes that tell the terminal to change colors.

有没有一种方法来捕捉彩色输出,包括着色?

Is there a way to capture colorized output, including the colorization?

推荐答案

一捕捉到彩色输出的方法是使用剧本命令。运行剧本开始,所有的原始输出被捕获到一个文件中的bash命令(名为打字稿默认情况下)

One way to capture colorized output is with the script command. Running script will start a bash session where all of the raw output is captured to a file (named typescript by default).

这篇关于可以彩色输出通过shell重定向被捕获?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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