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

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1758200353, '216.73.216.150', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/languages/sed/examples/ansi-escape(58): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78