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