3

I got this in a file:

\033[31mException log

And when I do:

less -R demo

I get no colors:

enter image description here

What am I doing wrong?

  • 1
    Note that an actual escape character (U+1B) would be represented as ESC in inverse colors, if you ran less demo, without -R. – wjandrea Jan 20 at 2:33
8

You need to put the actual escape code in the file. One way to do this would be:

echo -e "\033[31mException log\033[0m" > file.txt

Then less -R file.txt should be able to interpret the color code.

1

These characters are not a colour code sequence, but they are the sequence to tell some tools/programming-languages to create the desired character sequence.

e.g.

echo -e "\033[31mException log"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.