how to append some text by sed or awk after matching sequential two lines in file?
remark (need to ignore empty lines if exist)
for example
we want to append the text “this is the new line” after the following match lines in file
vopied 13783/tcp # VOPIED Protocol
vopied 13783/udp # VOPIED Protocol
this is the new line
lidia
As in your other question, I shall elucidate the steps.
Check for any line matching the
tcptext and apply a series of commands on it:I. Get the new line in pattern space (where the strings to be matched are stored)
II. Check if
tcpis matched on the first line andudpon the second line. If so append text to it.