grep

Echo n lines of trailing (after) context lines

grep -A n patern file

Echo n lines of leading (before) context lines

grep -B n patern file

Echo n lines of output context lines

grep -C n patern file

Colorize the patern match

grep –color=always

Invert (select non-matching lines)

grep -v pattern file

Count the lines matched

grep -c pattern file

Ignore casing

grep -i pattern path

To only display files with matches

grep -l pattern path

To only displays files without matches

grep -L pattern path

To stop after displaying n lines for each file

grep -m n pattern path

To print the line of the match inside the containing file

grep -n pattern path

Search recursively

grep -R pattern path

grep -r pattern path

Skip files matching pattern ???????:

grep -r –exclude=pattern

Matches only the entire word

grep -w word path

Lists the filename where the pattern was found – default

grep -H pattern path

Uncategorized