这个问题在这里已有答案:
我有这样一个文件:
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
但是无法正确使用)和我发现的其他回复找到了单词而不是句子,这让我感到困惑。
以下awk
可能会帮助你。
awk '/*** End copy here ***/{flag="";next}/*** Start copy here ***/{flag=1;next} flag' Input_file
sed -e '1,/^\*\*\* Start copy here \*\*\*$/d' -e '/^\*\*\* End copy here \*\*\*$/,$d' tmp.txt