我是一個noob當涉及到編碼,所以忍受着我...我試圖編寫一個腳本,將數據從3個單獨的文件輸入到文本文件中的3個特定位置 - 例如: 編輯閱讀更容易從多個文件位置匹配後追加文本
#start of script
start_of_line1_text "$1" end_of_line1_text
start_of_line2_text "$2" end_of_line2_text
start_of_line3_text "$3" end_of_line3_text
#output to text when done
$1 is the value in text1
$2 is the value in text2
$3 is the value in text3
我想用SED,但不能完全奏效瞭如何做到這一點做的......
或者剛插入爲$ 1字匹配random_text後?即:
sed '/start_of_line1_text/ a middle_of_line1_text' input
而且在更大的範圍 - 如果text1,2,3人在你怎麼能導入一次這些值1,每次保存新文件多個值嗎?因此,例如:
text1 =
a
b
c
text2 =
e
f
g
text3 =
h
i
j
#start of script
start_of_line1_text "line one of text1" end_of_line1_text
start_of_line2_text "line one of text2" end_of_line2_text
start_of_line3_text "line one of text3" end_of_line3_text
#output to text when done
則:
#start of script
start_of_line1_text "line two of text1" end_of_line1_text
start_of_line2_text "line two of text2" end_of_line2_text
start_of_line3_text "line two of text3" end_of_line3_text
#output to text when done
我不是挑剔的語言使用,我只是有點堅持以如何適應這一切在一起....
許多在此先感謝
我努力理解你想做什麼,但我不明白。看起來你混合了僞代碼和輸入/輸出;此外,文字過於簡單。每條線上它真的是一樣的嗎?可能不會。你可以通過更清楚你想要發生什麼,分離(僞)代碼和輸入/輸出,並顯示你到目前爲止嘗試過的東西來改善這個問題。 –