I am trying to replace the android:versionName value in the following manifest with the current date:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
coreApp="true"
package="com.btaudio"
android:versionName="0.7-191027"
android:sharedUserId="android.uid.system">
Here is my batch script with sed command:
chmod 777 AndroidManifest.xml
test=$(date '+%y%m%d')
sed 's|(?<=-).*?(?="\n)|'"$test"'|g' AndroidManifest.xml
My idea is to grab the text between "-" and the double quote that is followed by newline, the variable work fine after using delimiter.
Could anyone please explain to me why the regex expression is not recognized by sed, although on regex101 it show exactly the text that I want to replace (https://regex101.com/r/yHFkrV/1).
I have read about using -e, -E or -r para but none of those work for me. Also I have tried some delimiter on the expression but it does not seem to have any effect.
Edit: I am using sed (GNU sed) 4.2.2 on Ubuntu 16.04.3 LTS