Linux中输出匹配字符之后的第n行

 

001、

[root@PC1 test]# ls
a.txt
[root@PC1 test]# cat a.txt                     ## 测试数据
444 777
222 999
eee 333
222 666
111 ggg
sss fff
zzz mmm
nnn rrr
ttt hhh
[root@PC1 test]# awk '{if($0 ~ /^eee/) {tmp = NR + 3}; if(NR == tmp) {print $0}}' a.txt       ## 输出匹配eee字符串之后的第三行
sss fff

。 

 

posted @ 2024-02-10 10:49  小鲨鱼2018  阅读(12)  评论(0编辑  收藏  举报