Praj's Blog

Command line grep

Here’s a pretty nice combination of parameters for command line grep using egrep (which supports regex):

egrep -rHnC1 "bprajb" .

This will search in the current directory recursively through all files that match the word “praj” (regex boundary b tags) and return the file name and context (1 line either side of the match) with line numbers.

For example here’s the resut with the matching word highlighted as well on the terminal.