grep for special characters in Unix

后端 未结 6 520
你的背包
你的背包 2020-12-02 06:02

I have a log file (application.log) which might contain the following string of normal & special characters on multiple lines:

*^%Q&$*&^@$&*!         


        
6条回答
  •  醉酒成梦
    2020-12-02 07:04

    Tell grep to treat your input as fixed string using -F option.

    grep -F '*^%Q&$*&^@$&*!^@$*&^&^*&^&' application.log
    

    Option -n is required to get the line number,

    grep -Fn '*^%Q&$*&^@$&*!^@$*&^&^*&^&' application.log
    

提交回复
热议问题