Using sed to match a pattern and deleting from the line to the end of the file

后端 未结 5 1264
感动是毒
感动是毒 2021-01-01 10:59

I\'m trying to match a pattern from piped input and/or a file, and then remove from the matched lines to the end of the file, inclusive. I\'ve looked everywhere, but can\'t

5条回答
  •  孤城傲影
    2021-01-01 11:29

    Here's a regular expression that I think will do what you want it to: ^(?:(?!Files:).)+|\s*-----THIS STUFF IS USELESS-----.+ Make sure to set the dotall flag.

    Demo+explanation: http://regex101.com/r/xF2fN5

    You only need to run this one expression.

提交回复
热议问题