How to give a pattern for new line in grep?

前端 未结 6 612
予麋鹿
予麋鹿 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:31

    You can use this way...

    grep -P '^\s$' file
    
    • -P is used for Perl regular expressions (an extension to POSIX grep).
    • \s match the white space characters; if followed by *, it matches an empty line also.
    • ^ matches the beginning of the line. $ matches the end of the line.

提交回复
热议问题