Bash:你如何提取两个句子之间的所有行?

时间:2018-01-04 15:57:00

标签: bash sed terminal

我有一个这样的文件:

When, in the course of human events, 
it becomes necessary for one people to dissolve 
*** Start copy here ***
the political bonds which have connected them 
with another, and to assume among the powers of 
*** End copy here ***
the earth, the separate and equal station to 
which the laws of nature and of nature's God entitle them 

我想编写一行终端命令来提取*** Start copy here ****** End copy here ***之间的行,所以输出应为:

the political bonds which have connected them 
with another, and to assume among the powers of 

我该怎么做?我不想使用awk(我一直在玩sed,但无法正确使用)以及我发现的其他回复单词而不是句子,这让我感到困惑。

2 个答案:

答案 0 :(得分:1)

关注awk可能对您有帮助。

awk '/*** End copy here ***/{flag="";next}/*** Start copy here ***/{flag=1;next} flag'  Input_file

答案 1 :(得分:1)

sed -e '1,/^\*\*\* Start copy here \*\*\*$/d' -e '/^\*\*\* End copy here \*\*\*$/,$d' tmp.txt