Skip to content

Instantly share code, notes, and snippets.

Created October 4, 2011 21:37
Show Gist options
  • Save anonymous/1262904 to your computer and use it in GitHub Desktop.
Save anonymous/1262904 to your computer and use it in GitHub Desktop.
Highlight lines matching pattern
# Used as a drop-in replacement for grep that colors matching lines, but prints all lines
function highlight() {
local args=( "$@" )
for (( i=0; i<${#args[@]}; i++ )); do
if [ "${args[$i]:0:1}" != "-" ]; then
args[$i]="(${args[$i]})|$"
break
fi
done
grep --color -E "${args[@]}"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment