Print all lines between two patterns, exclusive, first instance only (in sed, AWK or Perl) [duplicate]
问题 This question already has answers here : How to print lines between two patterns, inclusive or exclusive (in sed, AWK or Perl)? (9 answers) Closed 1 year ago . Using sed, AWK (or Perl), how do you print all lines between (the first instance of) two patterns, exclusive of the patterns? 1 That is, given as input: aaa PATTERN1 bbb ccc ddd PATTERN2 eee Or possibly even: aaa PATTERN1 bbb ccc ddd PATTERN2 eee fff PATTERN1 ggg hhh iii PATTERN2 jjj I would expect, in both cases: bbb ccc ddd 1 A