I have the following properties in a file called myFile.gradle

 targetSdkVersion 28
 versionCode 22
 versionName "1.0.4"

I want to replace versionCode 22 with versionCode 23 with sed command on Mac terminal

This is what I try:

sed -ie "s/versionCode[[:space:]][[:digit:]]+/versionCode 25/g" myFile.gradle

Note that if I remove the + from [[:digit:]] , it works as expected - it replaces only the first digit, so versionCode 22 becomes versionCode 252.

Also, if I do [[:digit:]].* , it does the job , but I want to use digit not a wildcard.

0 Answers