I want to print all lines from a match up to a second match, not including that second match.
What I have so far does everything and does too much, in that it prints the second match as well.
Specifically, let's say I want to print everything starting on a line containing 'test', up to, but not including, the first line starting with a number or an open bracket '['.
This goes some way, but not all the way:
sed -n '/test/,/^[0-9]\|^\[/p' file
It is much easier to do this via awk
:
awk '/test/{p=1} /^([0-9]|\[)/{p=0} p' file
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments