linux中grep命令如何匹配制表符

 

1、测试数据

root@DESKTOP-1N42TVH:/home/test2# ls
a.txt
root@DESKTOP-1N42TVH:/home/test2# cat a.txt
d ees j
x e.s u
z e s u
w e     s u
root@DESKTOP-1N42TVH:/home/test2# sed -n l a.txt   ## 显示出制表符
d ees j$
x e.s u$
z e s u$
w e\ts u$

 

2、如何匹配制表符

root@DESKTOP-1N42TVH:/home/test2# ls
a.txt
root@DESKTOP-1N42TVH:/home/test2# cat a.txt
d ees j
x e.s u
z e s u
w e     s u
root@DESKTOP-1N42TVH:/home/test2# sed -n l a.txt
d ees j$
x e.s u$
z e s u$
w e\ts u$
root@DESKTOP-1N42TVH:/home/test2# grep '\t' a.txt
root@DESKTOP-1N42TVH:/home/test2# grep $'\t' a.txt      ## 在$符号,且使用单引号可以匹配制表符
w e     s u
root@DESKTOP-1N42TVH:/home/test2# grep $"\t" a.txt
root@DESKTOP-1N42TVH:/home/test2# grep "\t" a.txt

 

posted @ 2022-04-24 18:23  小鲨鱼2018  阅读(610)  评论(0编辑  收藏  举报