#!/bin/bash function highlight() { if [ "$1" == "--help" ] || [ "$1" == "-h" ]; then printf "usage: ./highlight [-i] ''[red|white|green|cyan]\n" printf " -[h?] : this message\n" printf " -i : case insensitive matching\n" printf " : standard regex, some character such as | must be escaped\n" printf " [rwgc] : the color to highlight with, white is default\n" printf "\n" return; fi if [ "$1" == "-i" ]; then case_ins="i" shift else case_ins="" fi regex=$1 color_code=37 case "$2" in r|red) color_code=31 ;; w|white) color_code=37 ;; g|green) color_code=32 ;; c|cyan) color_code=36 ;; esac sed -e "s/\($regex\)/\[1;$color_code;40m\1\/g$case_ins" }