I have a long list of strings separated by newlines and each section separated by a string starting with ~
(there are no other ~
in the file). I want to extend grep to find the ~
text right below the match.
Input:
abc
ads
acb
abc
acsa
acfs
~notthis
abc
ads
acb
xyz <-- pattern
acsa
acfs
~this <-- output
abc
ads
acb
abc
acsa
acfs
~no
Output when searching for xyz
:
~ this
With awk
I'd do something like
awk '/xyz/{x=1}x&&/~/{print;exit}' file
but I want to use grep if it can give me a performance advantage