End of line char ($) doesn't work inside square brackets

前端 未结 3 1541
一向
一向 2021-01-12 21:29

Putting $ inside square brackets doesn\'t work for grep.

~ $ echo -e \"hello\\nthere\" > example.txt
~ $ grep \"hello$\" example.txt 
hello
~         


        
3条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-12 22:21

    If you're trying to match end of line characters or the end of the string, you can use (|) like so "ABC($|\n)".

提交回复
热议问题