假設我有兩個文件。我如何執行以下操作,即將一個文件中的標記部分複製到另一個文件的某個位置?有些sed
命令會完成這項工作嗎?什麼是最實用的方法?複製和粘貼文本分組到另一個文件的優雅方式
文件#1:
This paragraph does not belong to the poem.
{ begin passage #1 }
When from a place he run away,
He never at the place did stay;
And while he run, as I am told,
He never stood still for young or old.
He often squeaked, and sometimes violent,
And when he squeaked he never was silent.
Though never instructed by a cat,
He knew a mouse was not a rat.
{ end passage #1 }
This as well does not.
文件#2:
There was a little guinea pig,
Who being little, was not big;
He always walked upon his feet,
And never fasted when he eat.
{ input passage #1 file #1 }
One day, as I am certified,
He took a whim, and fairly died;
And as I am told by men of sense,
He never has been living since.
我想有從插入文件#2文件#1的通道在給定的標記。幫助和想法都讚賞!
您是否期待'第1段(文件#1)'有不同的值,或者硬編碼的解決方案是否可以接受? – shellter