======================================================
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
======================================================
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
======================================================
Comments