Reputation: 1813
I have a multiple files named paramaters.txt
containing different parameters and their values:
param1 = vaue1
param2 = value2
param3 = value3
And I'd like to replace value of param2
and have
param1 = vaue1
param2 = value4
param3 = value3
I was trying to use sed
but I was able to do it if I know the string I want to replace, value2
in my case. But I don't know it (or rather it can be different in different files).
I would rather try to find string param2
and replace everything that is on the right side of it.
But I don't know how to do it.
Any hint will be appreciated.
Upvotes: 0
Views: 1131
Reputation: 533
An easy way to accomplish what you want is to use sed
to find the line with the parameter you want and replace the entire line. Something like this should work:
sed -i 's/^param2 =.*/param2 = value4/' file
Upvotes: 2