linux中删除匹配行及其后的若干行

 

1、

[root@rhel7pc1 test]# ls
a.txt
[root@rhel7pc1 test]# cat a.txt
1 k d f
2 x c g
3 z c b
4 f i j
5 e d g
6 i j e
[root@rhel7pc1 test]# sed '/x/, +1d' a.txt
1 k d f
4 f i j
5 e d g
6 i j e
[root@rhel7pc1 test]# sed '/x/, +2d' a.txt
1 k d f
5 e d g
6 i j e

 

posted @ 2022-04-10 14:52  小鲨鱼2018  阅读(73)  评论(0编辑  收藏  举报