Linux 中sed命令输出匹配字符的行号

 

001、

[root@PC1 test]# ls
a.txt
[root@PC1 test]# cat a.txt     ## 测试数
aa bbb
dd ff
77 dd
22 44
77 88
cc dd
ee ff
[root@PC1 test]# sed -n '/dd/p' a.txt    ## 输出匹配dd的行
dd ff
77 dd
cc dd
[root@PC1 test]# sed -n '/dd/=' a.txt      ## 输出匹配字符的行号
2
3
6

 。

 

posted @ 2024-07-13 21:01  小鲨鱼2018  阅读(4)  评论(0编辑  收藏  举报