原文件为get.txt, 取从start到end的内容
[root@oracle9i shell]# more get.txt
aaaaaaaa
bbbbbbb
.....
cccccccc
start
dddddddd
eeeeeeee
...
....
ffffffffffffffff
end
gggggggggg
............
hhhhhhh
方法一
[root@oracle9i shell]# awk '/^start$/,/^end$/' get.txt > to.txt
[root@oracle9i shell]# more to.txt
start
dddddddd
eeeeeeee
...
....
ffffffffffffffff
end
方法二
[root@oracle9i shell]# sed -n '/^start$/, /^end$/ p' get.txt > to1.txt
[root@oracle9i shell]# more to1.txt
start
dddddddd
eeeeeeee
...
....
ffffffffffffffff
end
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/7865774/viewspace-616088/ ,如需转载,请注明出处,否则将追究法律责任。