从shell脚本属性文件编辑属性值 [英] Edit a property value in a property file from shell script
本文介绍了从shell脚本属性文件编辑属性值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
标题说,所有。我需要更换一个属性值谁我不知道不同的值。
我想要这样的:
The title says all. i need to replace a property value whom i don't know to a different value. i'm trying this:
#!/bin/bash
sed -i "s/myprop=[^ ]*/myprop=$newvalue/g" file.properties
我得到的sed:-e前pression#1,烧焦19:未知选项
s'`
我认为问题是, $ NEWVALUE
是重新presents一个目录,以便它搅乱了一个字符串sed的。
I think the problem is that $newvalue
is a string that represents a directory so it messes up sed.
我该怎么办?
推荐答案
SED
可以使用比 /
其他字符作为分隔符,即使 /
是最常见的。当类似的事情处理的路径名,它往往是有帮助的使用像钢管( |
)而不是
sed
can use characters other than /
as the delimiter, even though /
is the most common. When dealing with things like pathnames, it's often helpful to use something like pipe (|
) instead.
这篇关于从shell脚本属性文件编辑属性值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文