linux中grep命令i匹配以制表符开头的行

 

1、测试数据

[root@rhel7pc1 test]# ls
test.txt
[root@rhel7pc1 test]# cat test.txt
e 5435.1 f d
        f 1 j k
 d f    e u
d j 1 j
[root@rhel7pc1 test]# sed -n l test.txt
e 5435.1 f d$
\tf 1 j k$
 d f\te u$
d j 1 j$

 

2、

[root@rhel7pc1 test]# ls
test.txt
[root@rhel7pc1 test]# cat test.txt
e 5435.1 f d
        f 1 j k
 d f    e u
d j 1 j
[root@rhel7pc1 test]# sed -n l test.txt
e 5435.1 f d$
\tf 1 j k$
 d f\te u$
d j 1 j$
[root@rhel7pc1 test]# grep "^\t" test.txt  ????

 

[root@rhel7pc1 test]# ls
test.txt
[root@rhel7pc1 test]# cat test.txt
e 5435.1 f d
        f 1 j k
 d f    e u
d j 1 j
[root@rhel7pc1 test]# sed -n l test.txt
e 5435.1 f d$
\tf 1 j k$
 d f\te u$
d j 1 j$
[root@rhel7pc1 test]# grep $'^\t' test.txt
        f 1 j k

 

3、匹配包含制表符的行

[root@rhel7pc1 test]# ls
test.txt
[root@rhel7pc1 test]# cat test.txt
e 5435.1 f d
        f 1 j k
 d f    e u
d j 1 j
[root@rhel7pc1 test]# sed -n l test.txt
e 5435.1 f d$
\tf 1 j k$
 d f\te u$
d j 1 j$
[root@rhel7pc1 test]# grep $'\t' test.txt
        f 1 j k
 d f    e u

 

posted @ 2022-04-09 21:00  小鲨鱼2018  阅读(240)  评论(0编辑  收藏  举报