For example, I\'d like to color the output of the locate
command so it\'s easily distinguished from the other terminal text.
It should work something li
norm="$(printf '\033[0m')" #returns to "normal"
bold="$(printf '\033[0;1m')" #set bold
red="$(printf '\033[0;31m')" #set red
boldred="$(printf '\033[0;1;31m')" #set bold, and set red.
somecommand | sed -e "s/someregexp/${boldred}&${norm}/g" # will color any occurence of someregexp in Bold red
printf "%s" "$red" ; locate something ; printf "%s" "$norm" # will color output of locate something in red
#I (ab)use printf "%s" "something", as it's more portable than echo,and easy to modify
There are many other ways (create a function/script that can colorize a regexp, for example, and then : somecommand | colorize -c green 'foo.*bar' 'other'
)