Reputation: 412
I'm looking to replace a line of text in a file. This is not a specific line #, but rather matching a certain parameter and then replace the entire line with what I want.
Looking into 'sed' seems to be an idea, problem is all the special chars included in the source/to replace strings that are confusing me in sed how to handle properly. I also tried these are parsed variables but with no results.
Eg:
Source line to match: PATH_FLOW=*ANYTHINGgoes*
To be replaced with: PATH_FLOW="file:///var/log"
sed -i 's/^PATH_FLOW=*/PATH_FLOW="file:///var/log"/g' /etc/sysconfig/random_file
Upvotes: 1
Views: 71
Reputation: 784898
You can use it like this:
sed -i.bak '/PATH_FLOW=/s~^.*$~PATH_FLOW="file:///var/log"~'
Upvotes: 1