How can I set the grep after context to be “until the next blank line”?

后端 未结 4 1071
伪装坚强ぢ
伪装坚强ぢ 2021-01-30 13:31

With grep I know how to set the context to a fixed number of lines. Is it possible to show a context based on an arbitrary string condition, like set after-context to \"until th

4条回答
  •  有刺的猬
    2021-01-30 13:38

    It sounds like you need sed:

    sed -n '/pattern/,/^$/p' file
    

    Don't print by default (-n). For lines that match /pattern/ up to an empty line /^$/, print.

提交回复
热议问题