Skip to content

Instantly share code, notes, and snippets.

@larsyencken
Created October 12, 2011 05:55
Show Gist options
  • Save larsyencken/1280401 to your computer and use it in GitHub Desktop.
Save larsyencken/1280401 to your computer and use it in GitHub Desktop.
#!/bin/bash
#
# highlight
#
# Highlight matching lines in the input. Like a less aggressive grep.
#
RED=$(echo -e '\033[31m')
NORMAL=$(echo -e '\033[00m')
function usage()
{
echo 'Usage: highlight <regex>'
echo
echo 'Highlights any input lines which match in red.'
echo
}
function highlight()
{
exec sed -u "s/${1}/${RED}\0${NORMAL}/g"
}
if [ $# != 1 ]; then
usage 1>&2
exit 1
fi
highlight "$1"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment