Is there a way to let the terminal show the raw escape sequence? (e.g. those used to control color)
I came across this UNIX.SE question, and want to filter "red" output ( Filter output of command by color)
However, the commands in the answers do not work for my output (e.g. the red in
git status for "Untracked files"). They do work for the examples there
echo -e '\033[00;31mtest\033[00m' | grep --color=none '[[:cntrl:]]'. Filtering with
grep --color=none '[[:cntrl:]]' works on my output but also shows text with other colors.
I guess the red I see must be a different red than
Is there a way to let terminal output raw escape sequences? (so that I can use the right sequence to filter the specific red color I see)
(bash, Ubuntu 18.04)
-- Update --
For clarification, my question is on how to show the raw escape sequence.
@egmont' answer using
script worked. Basically, I just needed to use
script to record the output and use one of the answers to the above question to find the red color text, e.g.:
script /tmp/a.txt git status exit cat /tmp/a.txt | grep -Eo $'\e\\[31m[^\e]*\e\\[?m'
The other answer/comments are also correct in pointing out that my usage of
git didn't get the color through the pipe.