好吧。感謝您的所有幫助。我從你那裏學習,要在sed中使用一個變量,我們必須使用「」而不是「'。但是,就我而言,在我使用''且沒有變量之前,它運行良好。在使用「」和變量($ title,$ web,$ desc)之後,它不再起作用,原因是什麼?謝謝。關於在sed問題中使用引號
之前
sed -i '0,/<item pop="N">/ { s/<item pop="N">/<item pop="N">\n <title>test1<\/title>\n <guid>test2<\/guid>\n <link>test3<\/link>\n <description><![CDATA[<p>test4<\/p>]]><\/description>\n <\/item>\n<item pop="N">/ }' /var/www/html/INFOSEC/english/rss/test.xml
後
sed -i "0,/<item pop="N">/ { s/<item pop="N">/<item pop="N">\n <title>News: $title<\/title>\n <guid>$web<\/guid>\n <link>$web<\/link>\n <description><![CDATA[<p>$desc<\/p>]]><\/description>\n <\/item>\n<item pop="N">/ }" /var/www/html/INFOSEC/english/rss/test.xml
我已經單獨運行它,而不是整個腳本 它變成錯誤-bash:![CDATA [:事件沒有發現,其實我不應該單獨運行,因爲我需要在變量中輸入內容
我沒有意識到techique之前,謝謝 –