Colorize grep automatically – pick a color, any color
Colorize Grep
Using grep syntax highlighting to colorize grep output is great for seeing where grep actually matched your regular expression or simple word on a line.
for x in {28..40}; do export GREP_COLOR=”1;$x;40″; grep Swap /proc/meminfo; echo “1;$x;40″; done
The code above loops through a bunch of color codes, exporting the GREP_COLOR variable for each one and grepping something with that color highlighting from /proc/meminfo, a place all linux users should have available and get output from.

In my bashrc I use GREP_COLOR in conjunction with GREP_OPTIONS=’–color=auto’ to colorize the output for me without affecting scripts or multiple commands chained together where I don’t want ANSI colors screwing up the output.

Grep Aliases
While we’re on the topic of bashrc, another tweak I throw in is alias’s for misspelled greps. I can’t be the only one that types gerp or hold’s shift too long after a pipe and types Grep accidentally, right?
|
1 2 3 |
alias 'gerp'='/bin/grep' alias 'Gerp'='/bin/grep' alias 'Grep'='/bin/grep' |