sed - Vagrant provision sed 命令返回错误
问题描述
我正在尝试运行一个 shellsed
命令作为config.vm.provision
config.vm.provision "shell", inline: <<-SHELL
systemctl stop firewalld
systemctl disable firewalld
swapoff -a
sed -i '/\/swapfile/s/^/#/g' /etc/fstab
SHELL
基本上我想要做的是评论/etc/fstab
文件中的交换条目。
但我得到一个错误:
master: Running: inline script
master: sed: -e expression #1, char 18: unterminated `s' command
The SSH command responded with a non-zero exit status. Vagrant
assumes that this means the command failed. The output for this command
should be in the log above. Please read the output to determine what
went wrong.
当我在盒子上运行时,sed 命令运行得非常好,但是当我将它作为我的 Vagrantfile 的一部分提供时出错。
知道为什么会这样吗?
解决方案
你能试一下吗?
$script = <<-SCRIPT
systemctl stop firewalld
systemctl disable firewalld
swapoff -a
sed -i '/\/swapfile/s/^/#/g' /etc/fstab
SCRIPT
Vagrant.configure("2") do |config|
config.vm.provision "shell", inline: $script
end
推荐阅读
- scrapy - `reddit` 是否会阻止爬虫移动到下一页?
- python - 如何在 python 中为用户输入的光标位置设置默认值?
- anylogic - 代理停止的来源
- mysql - 在 MySQL 中使用 COUNT 选择具有多个相同值的行
- algorithm - 具有不同复杂度的算法的两个不同步骤
- angular - HttpClientInMemoryWebApiModule.forRoot 中的 dataEncapsulation 选项是什么?
- python - Pandas 将索引为 0 1 2 ... 的 DataFrame [monthly data] 转换为特定日期年月范围
- cron - 一天中的 crontab 周不工作 - 它每天发送
- html - 如何从 iframe 内容延迟自动滚动
- regex - 正则表达式:Grafana 变量将连字符分隔的 IP 转换为点分隔的 IP