2017-03-17 35 views
0

我想替換以下字符串如何在linux中使用sed替換字符串中的單引號?

su - oracle -c "$agent_home/bin/emctl control agent runCollection ex01cel01:oracle_exadata oracle_exadata_configuration"

su - oracle -c "'$agent_home'/bin/emctl control agent runCollection ex01cel01 :oracle_exadata oracle_exadata_configuration"

注更換:額外的單引號覆蓋$ agent_home

請幫我

+1

的【如何逃脫在sed單引號?](http://stackoverflow.com/questions/24509214/how-to-escape-single-quote-in-sed) – Sundeep

+0

哪裏是可能的複製' sed(1)'呼籲這個問題?請不要濫用標籤。 –

回答

1

以下sed命令應該執行

sed "s|\$agent_home|'\$agent_home'|" 
+1

或'sed's/$ agent_home/\ x27&\ x27 /''爲了避免擔心在雙引號中逃脫shell解釋 – Sundeep

+0

感謝彼得它工作 –

相關問題