Monday, March 1, 2010

Grep commands

Grep recursively into a directory
grep -r "string" ./

Grep ignore case and recursive
grep -ir "string" ./

Grep ignore case, recursive and specific file type
grep -ir --include=*.vhd "string" ./

Grep ignore case, recursive, specific file type and list only matching file name
grep -ir -l --include=*.vhd "string" ./

Grep ignore case, recursive, specific file type, list only matching file name and only whole word matching
grep -ir -l -w --include=*.vhd "string" ./