Category Archives: Script

Add a background color to echo statements in a Bash script

To add a background color to your echo statements in a Bash script, you can use ANSI escape codes for text formatting, just like you did for text color. In this case, you’ll use codes for background colors. Here’s an example of how you can do it: #!/bin/bash # Text colors RED=’\033[0;31m’ GREEN=’\033[0;32m’ YELLOW=’\033[0;33m’ NC=’\033[0m’ … Continue reading Add a background color to echo statements in a Bash script

Convert diff output to colorized HTML

If you search the web you can find a number of references to programs/scripts that convert diff output to HTML. This is a bash version. The script expects “unified” diff output (diff -u) on its standard input and produces a self-contained colorized HTML page on its standard output. Consider the two files: #include <stdio.h> // main main() { printf(“Hello … Continue reading Convert diff output to colorized HTML