我正在尝试插入一行文本;
include /etc/nginx/sites-enabled/*;
在单词之后的下一行;
for more information.
在我的/etc/nginx/nginx.conf 中使用以下命令
sudo sed '/for more information.'/a include /etc/nginx/sites-enabled/*;' /etc/nginx/nginx.conf
但是每次我运行它,它都会返回
>
我不太擅长这类事情,所以我希望有人能帮助我。
干杯,
最佳答案
删除第二个单引号。这是多余的:
sudo sed '/for more information./a include /etc/nginx/sites-enabled/*;' /etc/nginx/nginx.conf
此外,因为 .
匹配 任何 字符并且您可能希望它只匹配一个句点,所以像这样转义它:
sudo sed '/for more information\./a include /etc/nginx/sites-enabled/*;' /etc/nginx/nginx.conf
或者这个:
sudo sed '/for more information[.]/a include /etc/nginx/sites-enabled/*;' /etc/nginx/nginx.conf
关于linux - CentOS 使用 sed 不工作后插入新的文本行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48676099/