我試圖使用的代碼,我發現這裏:Insert contents of a file after specific pattern match如何插入文件的內容線路賽後當逃脫反斜槓
然而,當我添加一個反斜槓代碼,這是行不通的。那麼,我按照這裏的說明:Slash and backslash in sed更改sed
中的分隔符。但是,當我這樣做時,插入(應該是幾行)會變成數千。
這裏是我的嘗試:
sed ':<\tag>: r file1.txt' file2.txt
例子:
FILE1.TXT
Hello World 1
Hello World 2
FILE2.TXT:
<thanks>
<tag>
<example>
<new>
<\new>
<\example>
<\tag>
<\thanks>
所需的輸出:
<thanks>
<tag>
<example>
<new>
<\new>
<\example>
<\tag>
Hello World 1
Hello World 2
<\thanks>
如果你可以請幫我在一行匹配後插入文件內容,同時轉義一個反斜槓,我真的很感激它。
我做了交換file1和2.現在修復。但是,我沒有得到那個輸出:-( – DomainsFeatured
你還需要用另一個反斜槓來轉義反斜線。 – karakfa
是的,我已經試過'<\\tag>'和'<\\\tag>'前兩個都不適合我 – DomainsFeatured