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

问题描述 投票:0回答:2

我有这样一个文件:

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但是无法正确使用)和我发现的其他回复找到了单词而不是句子,这让我感到困惑。

bash sed terminal
2个回答
1
投票

以下awk可能会帮助你。

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

1
投票
sed -e '1,/^\*\*\* Start copy here \*\*\*$/d' -e '/^\*\*\* End copy here \*\*\*$/,$d' tmp.txt
© www.soinside.com 2019 - 2024. All rights reserved.