我需要在xml文件的version属性值中添加一个内部版本号:
<widget id="com.test.enterprise.operationsnew" version="2.4.2.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">在我的bash脚本中,我尝试过:
BUILD_NUMBER=1
VERSION="$(xmllint \
-xpath 'string(//*[local-name()="widget"]/@version)' config.xml | \
cut -f1-3 -d.)"
CFBundleVersion="${VERSION}.${BUILD_NUMBER}"
sed -i '' \
-e 's#version="[0-9].[0-9].[0-9].[0-9]"#version="${CFBundleVersion}"#g' \
config.xmlCFBundleVersion变量会插入,但不会被解析:
<widget id="com.test.enterprise.operationsnew" version="${CFBundleVersion}" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">我怎样才能用sed正确地做到这一点?
发布于 2017-07-13 20:51:00
sed -e 's#version="[0-9].[0-9].[0-9].[0-9]"#version="'${CFBundleVersion}'"#g' config.xml在变量两边添加单引号以展开它。
https://stackoverflow.com/questions/45080826
复制相似问题