bash 腳本的新手,我正在嘗試自動化一些標準的服務器設定命令。
當我運行以下我一直使用的 sed 命令時
sed 's/#Port 22/Port 55/' /etc/ssh/sshd_config
該命令執行沒有問題,但是當我將它放入 bash 腳本時,我得到
ssh -p [email protected] sed 's/#Port 22/Port 55/' /etc/ssh/sshd_config
它失敗了:sed: -e expression #1, char 7: unterminated s'命令`
注意:IP 和埠是為了帖子的虛假資訊。非常感謝任何和所有幫助。
uj5u.com熱心網友回復:
這是因為參考。嘗試:
ssh -p [email protected] "sed 's/#Port 22/Port 55/' /etc/ssh/sshd_config"
不帶引號,你實際上試圖運行sed s/#Port 22/Port 55/ /etc/ssh/sshd_config呼叫sed腳本,它試圖s/#Port上的檔案22/Port,55/和/etc/ssh/sshd_config。
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/407703.html
標籤:
