Saturday, February 26, 2022

[SOLVED] How to show only next line after the matched one?

Issue

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.


Solution

you can try with awk:

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


Answered By - Michał Šrajer
Answer Checked By - Robin (WPSolving Admin)