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 '19 at 2:33

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.


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.


echo -e "\033[31mException log"

Test that your terminal actually supports the colours by running:

cat your_file.txt

If your file has colour codes, your terminal will show them. If not, then either 1) your term isn't configured to support it or 2) you've entered incorrect codes.

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.