I would like to do the following by using sed
case 1:
*here is some random text constant=randomValue some more random text*
I would like to replace randomvalue directly after constant= while keeping the rest of the line intact so the result would look like:
*here is some random text constant=substituteValue some more random text*
case2:
*here is some random text constant= randomValue some more random text*
similar to the first one but with a space after the constant= string, so the output would be
*here is some random text constant= substituteValue some more random text*
For case one i've been trying to use:
echo $line | sed 's/server=.*\ /sever=\<SrvrName\>/'
You can use this sed:
sed 's/\( constant = *\)[^ ]*/\1substituteValue/' <<< "$line"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With