如何在通过 grep 进行管道传输后保留命令的彩色输出

问题描述 投票:0回答:1

举个例子,

systemd status weechat |grep Active

systemd 的输出根据状态为绿色或红色。

通过 grep(或其他命令,如 tail,...)进行管道传输时如何保持这一点?

有--color,但不是那个。

.

bash colors grep pipe
1个回答
0
投票

使用

script
保持颜色:

script -qec systemd status weechat |grep Active
© www.soinside.com 2019 - 2024. All rights reserved.