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 e w e
5 z c x
6 e d g
7 i j e
[root@rhel7pc1 test]# grep -A 1 -w "x" a.txt
2 x c g
3 z c b
--
5 z c x
6 e d g
[root@rhel7pc1 test]# sed -n '/x/, +1p' a.txt
2 x c g
3 z c b
5 z c x
6 e d g

 

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