I am taking the version code from user input and trying to replace the existing version code with the new one.
The file which contains version code is named "Version.gradle", it contains
defaultConfig {
applicationId "com.service_app"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0"
}
I am able to get the version from user, but I don not know how to replace the new version code with exiting one. I am using the below pattern to fetch the existing version code.
echo "Enter versionCode"
read versionCode
replacement=$(sed 'versionCode=\"(\\d+)\"' Version.gradle)
replacement=${versionCode}
sed "s/PATTERN/$replacement/g" Version.gradle
Current Output:
command : sed e version.sed
Enter versionCode
2
sed: -e expression #1, char 22: expected newer version of sed
sed: can't read Version.gradle: Permission denied
Expected Output:
In version.gradle file, 2 should replace the already existing version code.