[Editorial insertion: Possible duplicate of the same poster's earlier question?]
Hi, I need to extract from the file:
first
second
third
using the grep command, the following line:
second
third
How should the grep command look like?
Instead of grep
, you can use pcregrep
which supports multiline patterns
pcregrep -M 'second\nthird' file
-M
allows the pattern to match more than one line.