Grep for power users

I am constantly grepping old code bases, and new, for strings within files. The problem comes when I keep running into the same issues.

  • .svn
  • .git
  • .old
  • .png, jpg, jpeg, gif...
  • .bak
  • .min
I also love to have the color option and line number option, but tend to forget about it.

  • line numbers
  • file names
  • color highlighting
  • exclude binary files!
Here is the alias that I like to set in my .bash_profile...

alias grep='grep --line-number --with-filename --color --exclude="*\.min*" --exclude-dir="\.{svn,git}" --text --exclude="*\.{png,jpg,jpeg,gif,new,bak,old,~}"'

The exclude image extensions and --text (no binary) may be redundant, but I would rather be extra cautious.


Hope this helps others!


Popular Posts