shell script合併兩個檔案 - Linux

Sarah avatar
By Sarah
at 2010-06-18T08:06

Table of Contents

※ 引述《DRLai (蘇打)》之銘言:
: 想請問該如何利用shell script合併兩個檔案呢?
: 我有兩個檔案,內容分別如下
: a.txt
: -----
: (一堆程式碼)
: {REPLACE}
: (一堆程式碼)
: b.txt
: -----
: (額外的程式碼)
: 我想要做的事情是,把b.txt的東西塞到a.txt中的{REPLACE}這邊
: 原本想說使用sed可以作到,但發現sed只能取代當行或單字
: 沒辦法取代多行的
: 另一個想到的方法是使用
: cat a.txt | while read inputline 這樣的方式
: 但是程式碼排版會亂掉,縮排消失
: 有什麼好得方法嗎?
: (當然,我知道可以用c++之類的寫個程式就好XD只是想瞭解有沒有script解決方案)
: 感謝m(_ _)m

cat a.txt | sed '/{REPLACE}/,$d' > a.txt.top
cat a.txt | sed '1,/{REPLACE}/d' > a.txt.bottom

cat a.txt.top b.txt a.txt.bottom > c.txt


--
Tags: Linux

All Comments

xwindow 即時資訊

Olivia avatar
By Olivia
at 2010-06-18T01:26
想請問一下各位,如何看正在跑的xwindow是使用那個driver module? 我想讓vbox vm debian使用guest addition給的and#34;vboxvideoand#34; module。 可是發現連xorg.conf壓根沒存在過!以往要在xorg.conf中指定driver, ...

新手發問

Isabella avatar
By Isabella
at 2010-06-17T23:58
※ 引述《KHJS (Kathy )》之銘言: : 最近原PO想試著裝LINUX在原PO的小筆電上 : 爬了很多文 : 還沒決定要用哪一版的LINUX,倒是有幾個問題想請鄉民們解答 : 1)64Bit 跟32Bit 用起來差在哪? : 2)UBUNTU 似乎比較多人用,可是10.04真的有比9.10 糟嗎? ...

virtual box 直讀實機

Xanthe avatar
By Xanthe
at 2010-06-17T21:14
※ 引述《virtuemood (小毛)》之銘言: : 2. 建立 virtual box 中的 guest OS : * 如一般程序,唯虛擬磁碟使用以下指令所建立之映像檔 : VBoxManage internalcommands createrawvmdk -filename ...

編譯driver的錯誤 SA_INTERRUPT

Kyle avatar
By Kyle
at 2010-06-17T18:50
※ 引述《longrider (龍騎士2)》之銘言: : 我在編譯 driver 時, 發生了幾個錯誤 : error: and#39;SA_INTERRUPTand#39; undeclared (first use in this function) : error: and#39;SA_SHIRQand ...

編譯driver的錯誤 SA_INTERRUPT

Emma avatar
By Emma
at 2010-06-17T17:35
我在編譯 driver 時, 發生了幾個錯誤 error: and#39;SA_INTERRUPTand#39; undeclared (first use in this function) error: and#39;SA_SHIRQand#39; undeclared (first use in thi ...