shell实现apktool.yml的versionCode修改

#!/bin/bash

#文件路径
file_path="/Users/DexLin/Desktop/项目/shell练习/测试/API22_56/apktool.yml"

#要替换的versionCode值
versionCode=40

while read line
do
line_length=${#line}
if [ $line_length -ge 11 ]
then
each_line=${line:0:11}
if [ $each_line = "versionCode" ]
then
 ver_length=`expr ${#line} - 15`

#截取versionCode的值
 ver_code=${line:14:$ver_length}
 
 #生成新的文件实现替换
 cat $file_path | tr $ver_code $versionCode > apktool.yml
fi
fi

done < $file_path

你可能感兴趣的:(shell实现apktool.yml的versionCode修改)