I am trying to use the sed program to replace two lines of text in a config file using bash variables, the line replacement works however there is a extra space at the start of the line.
My commands are as follows:
replacement="computer_id = $server_ref"
(where $server_ref is a user entered variable)
and then:
sed "/computer_id/c \ ${replacement}" -i slapos.cfg
The other line being replaced uses just the same commands just changes a different variable in the config file.
The ouput of this change looks like
computer_id = something
when it should be
computer_id = something
which results in crashing the program using the config as it is not excepting that space.
Might be better to do it like this:
The program which reads the configuration file isn’t very robust if extra whitespace crashed it.