I've seen many more or less related topics, but all I found discuss how to color awk
output. I need to preserve the color that was provided as awk
input. For example, now I have:
./some_command
(red_text) (blue_text) (green_text)
./some_command | awk -F' ' '{print $1}'
(red_text) # < but the color is standard terminal color, not red anymore
How to keep the original coloring in the awk
output?
some_command may have an option to force color even when it's connected to a terminal, for example with grep it would be
--color=always
. If it doesn't though you have to trick some_command into thinking it's connected to a terminal. Usingscript
for example:There would be no color if you ran grep without
script
: