How to give a pattern for new line in grep?

前端 未结 6 602
予麋鹿
予麋鹿 2020-12-02 06:19

How to give a pattern for new line in grep? New line at beginning, new line at end. Not the regular expression way. Something like \\n.

6条回答
  •  既然无缘
    2020-12-02 06:38

    Thanks to @jarno I know about the -z option and I found out that when using GNU grep with the -P option, matching against \n is possible. :)

    Example:

    grep -zoP 'foo\n\K.*'<<<$'foo\nbar'

    Prints bar

提交回复
热议问题