用SED替换一个变量
我的文件中有此字符串
$vnet_address
用:
$vnet_address=10.1.0.0/16
运行此命令时会替换出错误
sed -i "/\$vnet_address/ s//$vnet_address/"
,并且在我的bash运行时间中有这个变量,我想 我的变量。
怎么去做?
I have this string in my file
$vnet_address
And i have in my bash run time this variable which i want to replace my string with:
$vnet_address=10.1.0.0/16
I get an error when i run this command:
sed -i "/\$vnet_address/ s//$vnet_address/"
And i believe it is because of the slash character '/' in my variable.
How to go about it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用
注意:
,
$
通过文字\
角色正确逃脱了“ https://ideone.com/6jarvn” rel =“ nofollow noreferrer”>在线演示:
You can use
Note:
,
$
is properly escaped with a literal\
characterSee the online demo: