Search notes:

sed example: colorizing a file

This examples replaces RED, YLW and GRN with the ANSI escape sequences for red, yellow and green. This can be used as a template to colorize files (for example errors and warnings in a log file).

The script

sed 's/RED/\x1B[31m/g;
     s/GRN/\x1B[32m/g;
     s/YLW/\x1B[33m/g;
     s/END/\x1B[0m/g' testfiles/colorize
Github repository about-sed, path: /ansi-escape

The input file - colorize

REDErrorsEND might be printed in red,
YLWWarningsEND in yellow, and GRNinfosEND
in green.
Github repository about-sed, path: /testfiles/colorize

See also

sed testfile: lorem ipsum dolor
sed examples

Index