« Amazing Lenovo Support Experience | Main

grep --color

I use grep a lot. Today I realized that others might not know that GNU grep can highlight matches, or how to combine it with less. So here's part of my Bash config, and some examples uses:


alias grep='grep --color=auto'
alias egrep='egrep --color=auto'

function legrep {
  egrep --color=yes "$@" | less -R
}

$ legrep '[Gg]nome' */*.xml
$ legrep -i foo /usr/share/dict/words
$ grep bar | egrep -v 'baz|qux' | legrep bar