linux 中 grep命令检测出$符号

 

001、

[root@pc1 test2]# ls
a.txt
[root@pc1 test2]# cat a.txt              ## 测试数据
xx yy$ kk
ff ee 88
uu ee ww$
[root@pc1 test2]# grep "$" a.txt         ## grep直接检测,检测不到
xx yy$ kk
ff ee 88
uu ee ww$
[root@pc1 test2]# grep "\$" a.txt        ## 增加转义字符,检测不到
xx yy$ kk
ff ee 88
uu ee ww$
[root@pc1 test2]# grep "[$]" a.txt       ## 正确做法,加中括号, 目前不知道为什么
xx yy$ kk
uu ee ww$

 

。 

 

posted @ 2024-03-01 16:02  小鲨鱼2018  阅读(94)  评论(0)    收藏  举报