How to show only next line after the matched one?

facha picture facha · Sep 17, 2011 · Viewed 245.7k times · Source
grep -A1 'blah' logfile

Thanks to this command for every line that has 'blah' in it, I get the output of the line that contains 'blah' and the next line that follows in the logfile. It might be a simple one but I can't find a way to omit the line that has 'blah' and only show next line in the output.

Answer

Michał Šrajer picture Michał Šrajer · Sep 17, 2011

you can try with awk:

awk '/blah/{getline; print}' logfile