How to select lines between two marker patterns which may occur multiple times with awk/sed

前端 未结 9 1357
离开以前
离开以前 2020-11-22 04:41

Using awk or sed how can I select lines which are occurring between two different marker patterns? There may be multiple sections marked with these

9条回答
  •  清歌不尽
    2020-11-22 05:19

    From the previous response's links, the one that did it for me, running ksh on Solaris, was this:

    sed '1,/firstmatch/d;/secondmatch/,$d'
    
    • 1,/firstmatch/d: from line 1 until the first time you find firstmatch, delete.
    • /secondmatch/,$d: from the first occurrance of secondmatch until the end of file, delete.
    • Semicolon separates the two commands, which are executed in sequence.

提交回复
热议问题