Given: sed -e '/pattern1/,/pattern2/!d' file.org
How can I match the first occurrence of the lines between pattern1 and pattern2, but not the rest?
For example:
pattern1
aaaa
pattern2
pattern1
bbb
pattern
should output:
aaa
Alternatives solutions (using grep
, awk
or whatever) are welcomed.