gpt4 book ai didi

regex - 大厨 Knife ssh sed命令

转载 作者:塔克拉玛干 更新时间:2023-11-03 01:23:57 25 4
gpt4 key购买 nike

我用 knife ssh 运行一个 sed 命令:

knife ssh 'name:mynode' 'sudo sed -i 's/https:\/\/test1.mydomain.com/https:\/\/test2.mydomain.com/g' /etc/chef/1.rb' -x myuser ./mypem.pem

我遇到了一个错误:

sed: -e expression #1, char 11: unknown option to `s'

如果我尝试

knife ssh 'name:mynode' "sudo sed -i 's/https:\/\/test1.mydomain.com/https:\/\/test2.mydomain.com/g' /etc/chef/1.rb" -x myuser ./mypem.pem

Error:

sed: can't read ./mypem.pem: No such file or directory

如果我试试

knife ssh 'name:mynode' "'sudo sed -i 's/https:\/\/test1.mydomain.com/https:\/\/test2.mydomain.com/g' /etc/chef/1.rb'" -x myuser ./mypem.pem
Error:
bash: sudo sed -i s/https://test1.mydomain.com/https://test2.mydomain.com/g /etc/chef/1.rb: No such file or directory

命令在机器上运行:

sudo sed -i 's/https:\/\/test1.mydomain.com/https:\/\/test2.mydomain.com/g' /etc/chef/1.rb

为什么会这样?

最佳答案

创建配方并使用 knife ssh 运行它

bash 'sed' do
code <<-EOH
sudo sed -i 's,https://test1.mydomain.com,https://test2.mydomain.com,g' /etc/chef/1.rb
EOH
end

关于regex - 大厨 Knife ssh sed命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38460858/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com