How to grep for the dollar symbol ($)?

后端 未结 6 409
轮回少年
轮回少年 2020-12-04 18:37
% cat temp
$$$ hello1
$$  hello2
    hello3
##  hello4
    hello5 $$$
% cat temp | grep \"$$$\"
Illegal variable name.
% cat temp | grep \"\\$\\$\\$\"
Variable name          


        
6条回答
  •  渐次进展
    2020-12-04 19:38

    When you use double quotes " or none use double\: "\\\$\\\$\\\$"

    cat t | grep \\\$\\\$\\\$ 
    

    if you use in single quotes ' you may use:

    cat t | grep '\$\$\$'
    

提交回复
热议问题