sed: return last occurrence match until end of file

前端 未结 6 1443
名媛妹妹
名媛妹妹 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:12

    If you're happy with an awk solution, this kinda works (apart from getting an extra blank line):

    awk '/^Statistics/ { buf = "" } { buf = buf "\n" $0 } END { print buf }' input.txt
    

提交回复
热议问题