shell 正则取出中间文本。

文件名称为

build.gradle

所在行内容为

#appVersionCode   : 20220811, 

取出shell的脚本为

  APP_VERSION_CODE=$(egrep "appVersionCode   :(.*?)," build.gradle -o | sed 's/appVersionCode   : //g' | sed 's/\,//g' | sed 's/ //g')

sed语法解释下 替换文本

sed 's/被替换文本/替换文本/s'

egrep = grep -e 意思为。匹配正则内容

猜你喜欢

转载自blog.csdn.net/mp624183768/article/details/126306468