Created
October 12, 2011 05:55
-
-
Save larsyencken/1280401 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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