I have the need to replace a single line in multiple files and have been playing around with sed for a solution. I am encountering this error:
sed: -e expression #1, char 31: unterminated `s' command
When trying to run a bash script with the following line contained within:
sed -i.bak "s/some-text-string/some-text-string ${stringVar}/" *.ext
I understand that it's the whitespace that is likely causing this issue but I cannot find a solution anywhere. I need to preserve the whitespace in the replacement. I have looked into appending the string but have not been able to get very far using other functions either.
I am probably approaching the problem incorrectly and feel like I should be using a different function, however I don't have a large net of experience with sed or bash and have hit a brick wall.
If anyone could shed some light on a possible solution it would be greatly appreciated.
$stringVar
when the command is failing?$stringVar
is set to a character string, specifically 'vpnLoginCreds'. No special characters, no spaces, just that exact text string. The answer provided by choroba has solved this issue, but I am still curious as to why it was not possible with 'sed' when it should be able to deal with the whitespace.