sed: return last occurrence match until end of file

前端 未结 6 1454
名媛妹妹
名媛妹妹 2020-12-10 15:29

Using sed, how do I return the last occurance of a match until the End Of File? (FYI this has been simplified)

So far I\'ve tried:

sed -n \'/ Statist         


        
6条回答
  •  悲哀的现实
    2020-12-10 16:05

    This might also work, slightly more simple version of the sed solution given by the others above:

    sed -n 'H; /^Statistics |/h; ${g;p;}' logfile.log
    

    Output:

    Statistics |
       Stuff
    Error: error type one
    Error: error type two
    

提交回复
热议问题