This will update your file:
sed -i "/property.name=/ s/=.*/=newValue/" yourFile.properties
This will print to a new file.
sed "/property.name=/ s/=.*/=newValue/" yourFile.properties > newFile.properties
This is how you update several properties
sed -i -e "/property.name.1=/ s/=.*/=newValue1/" -e "/property.name.2=/ s/=.*/=newValue2/" yourFile.properties
Guru sed can blame me, because this is not the right way to do this (for example, I did not avoid the dots), but I consider this the best option if you do not want to sacrifice readability.
Here's an extended discussion: How do I use sed to modify my configuration files with flexible keys and values?
DenisS
source share