Skip to content

Instantly share code, notes, and snippets.

@troelskn
Created July 3, 2009 11:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save troelskn/140060 to your computer and use it in GitHub Desktop.
Save troelskn/140060 to your computer and use it in GitHub Desktop.
#!/bin/bash
LINE_COLOR=`echo -en '\e[92m'`
LINE_COLOR_RESET=`echo -en '\e[00m'`
MATCH_COLOR=`echo -en '\e[1m\e[33m'`
MATCH_COLOR_RESET=`echo -en '\e[22m\e[92m'`
PATTERN=""
if [ $# = 0 ]
then
echo "Usage: [PATTERN, PATTERN, ...]"
exit 1
fi
shift $(($OPTIND - 1))
for ARG in $*
do
#APPEND=`echo $ARG | sed "s/:\*$/:[0-9]+/g"`
APPEND="s/\(^.*\)\($ARG\)\(.*$\)/$LINE_COLOR\1$MATCH_COLOR\2$MATCH_COLOR_RESET\3$LINE_COLOR_RESET/g"
if [ -n "$PATTERN" ]
then
PATTERN="$PATTERN;$APPEND"
else
PATTERN="$APPEND"
fi
done
#echo "PATTERN = $PATTERN"
sed -e $PATTERN
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment