我可以使用以下命令通过硬编码来更改目标值。
sed -ie s/^target=.*/target=google.com/ url.properties
但是,如果我使用变量,我会报错。我不知道sed命令如何全部工作。我只需要设置构建系统即可。
url = google.com
sed -ie s/^target=.*/target=$url/ url.properties
sed错误:-e表达式#1,字符25:未终止的s命令
因为您URL
可能包含/
将bash解释为sed语法的问题,所以可能会发生此问题,因此类似的https/www.google.com
最终结果是:
sed -ie 's/^target=.*/target=https/www.google.com/' url.properties
我建议分隔任何特殊字符,以免sed
引起混淆:
url=google.com
url=`echo $url | sed -e "s/\//\\\\\\\\\//g"` # delimits backslash in URL's
sed -ie "s/^target=.*/target=$url/" url.properties
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句