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 @   小鲨鱼2018  阅读(678)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 单元测试从入门到精通
· 上周热点回顾(3.3-3.9)
· winform 绘制太阳,地球,月球 运作规律
历史上的今天:
2021-04-24 R语言中while循环
2021-04-24 R语言中for循环和while循环求1-100的和
2021-04-24 R语言中if判断语句
2021-04-24 R语言中利用sapply函数提取列表中元素
2021-04-24 R语言中scale函数
2021-04-24 R语言中apply函数
2021-04-24 R语言中大小写转换
点击右上角即可分享
微信分享提示