Monday, February 4, 2008

Grep Tricks

Grep Tricks #1
How to select multiple lines with grep before and after the matched pattern .

grep -B1 -A2 "DMA" message.txt

B[n]          n lines before matched pattern
A[n]          n lines after matched pattern

Grep Tricks #2
How to display(print) the line numbers of the matched pattern with grep.

grep -n "DMA" message.txt

n              prints line no

1 comment:

firstohit said...

this was helpful. thanks

OK GOOGLE on Samsung Galaxy S7 doesn’t work

To make Ok Google detection work on Galaxy S7 (Galaxy series phones) we need to perform a couple of steps. 1. As long as Samsung S vo...