Reputation: 4627
Im using cordova to build an app for android but cannot set the android:minSdkVersion in the AndroidManifest.xml file.
So i decided to modify this file each time i start building the app with a script i wrote.
I want to change the line:
<uses-sdk android:minSdkVersion="10" android:targetSdkVersion="19" />
to this:
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="19" />
Since cordova does not allow me to set this using the config.xml (only phonegap build allows, but i use cordova only) i need to modify the xml on my own.
I would like to replace whats inside mindSdkVersion to 14.
How can i do that?
I tried this:
sed 's/minSdkVersion="(.*)"/minSdkVersion="14"/g' AndroidManifest.xml
but it still gives me the uses-sdk line unchanged.
Whats wrong with my regexp?
Upvotes: 1
Views: 145
Reputation: 189317
There are two problems with your regex.
The parentheses are apparently interpreted as literal parentheses by your sed
dialect. They are useless anyway, so you don't need to fix that -- just remove them.
.*
is greedy and would match up to just before the last double quote.
With these remarks, the fix is easy.
sed 's/minSdkVersion="[^"]*"/minSdkVersion="14"/g' AndroidManifest.xml
Upvotes: 1
Reputation: 3239
Three things:
(.*)
with \(.*\)
You match too much, try
sed 's/minSdkVersion="[0-9]+"/minSdkVersion="14"/g' AndroidManifest.xml
If you want to modify the file, use -i
to change the file.
Upvotes: 1