Must be doing something silly here.
I have a file called 'test'. The file contains only one line -
versionName '2.0.0'
I want to programmatically replace the 2.0.0 value dynamically. Can't figure out why the following command not working -
sed -i '' 's/versionName "[0-9.]*"/versionName "'${MAJOR_VERSION}'"/' test
here, MAJOR_VERSION is a variable.
Please let me know if I can provide more info.
Try
sed -i '' "s/versionName '[0-9.]*'/versionName '${MAJOR_VERSION}'/" test
There were a couple of issues :
eg:
$ export MAJOR_VERSION=xyz
% echo "versionName '2.0.0'" > test
$ sed -i '' "s/versionName '[0-9.]*'/versionName '${MAJOR_VERSION}'/" test
$ cat test
results in :
versionName 'xyz'
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.