zl程序教程

您现在的位置是:首页 >  其他

当前栏目

shell 正则取出中间文本。

shell 文本 正则 中间 取出
2023-09-27 14:27:48 时间

文件名称为

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 意思为。匹配正则内容