RockPaperScissors

LizardSpock

Basic Grep Usage

| Comments

Grep is a unix (and mac os x) command line tool to search files for text.
1) Search for all files containing ‘text’ in current directory.

grep text *

2) Addline number to found matches.

grep -n text *

3) Search for all files containing ‘text’ in current and sub directories.

$ grep -R text *

4) Search for files containing ‘text’ in word only mode (Perl regular expressions).

$ grep -P '\btext\b' *

5) and remove ‘//’ comments.

$ grep -P '\btext\b' * | grep -v -P '://'

Remember for more info

$ man grep
$ info grep

Comments