Created
October 4, 2011 21:37
-
-
Save anonymous/1262904 to your computer and use it in GitHub Desktop.
Highlight lines matching pattern
This file contains 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
# 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