sed输出指定两行 # 输出正则匹配的两行,之间的行,包括正则匹配到的行 root@bwhhkle:~# cat tmp 1 2 3 4 5 6 root@bwhhkle:~# sed -n '/2/,/5/p' tmp 2 3 4 5 # 不包括正则匹配的行 root@bwhhkle:~# sed -n '/2/,/5/{//!p}' tmp 3 4 # 只输出正则匹配到的两行 root@bwhhkle:~# sed -n '/2/,/5/{//p}' tmp 2 5 Tags: sed详解 Read more articles Previous Postsed行寻址范围 Next Postsed正则 You Might Also Like bmqp代码更新脚本 September 19, 2019 shell生成随机字符串 July 1, 2014 sed删除多余的空行 September 8, 2015