0
我试图用sed来替代配置文件中的特定行:Sed:如何插入包含单个刻度的模式?
因为我想更换线的模式是:
ALLOWED_HOSTS.*
我要插入的文本是:
'$PublicIP' (Including the single ticks)
但是当我运行命令:
sed 's/ALLOWED_HOSTS.*/ALLOWED_HOSTS = ['$PublicIP']/g' /root/project/django/mysite/mysite/settings.py
行更改为:的
ALLOWED_HOSTS = [1.1.1.1]
代替:
ALLOWED_HOSTS = ['1.1.1.1']
我应如何编辑命令,包括单蜱虫呢?
使用'\ x27'代表单引号... – Sundeep
名次sible重复[如何在sed中单引号转义?](http://stackoverflow.com/questions/24509214/how-to-escape-single-quote-in-sed) – Sundeep