I have a script that stores text in a file. Some of that text has bash color espcaed characters that I would like to be used when I display the content of that file in a bash shell. How can this be achieved.
Fox example, ScriptOutput.txt contains
Server is \e[92mRUNNING\e[0m
I would normally cat the file and get the content, but cat will not color the "RUNNING" section of that line in the text file. I also tried
echo $(cat ScriptOutput.txt)
but it will print everything in that file in a single line, which is useless for me. Any ideas how to print the content of that file with the colors specified in each line?
Thank you
xxd
) of one coloured line from the file?less
can interpret ANSI escape codes if called withless -R
(can also be set as an environment variable,LESS='-R'
).echo "$(< ScriptOutput.txt)"
(same ascat
) with quotes would keep the newlines.