When using envsubst to replace values in a file, it creates a newline when it appends to a string. How do I prevent it from inserting a newline when saving it to a new file?
Environment Variable:
foo=bar
File:
$foo\\text\\word,$foo\\text2\\word2,$foo\\text3\\word3
Command:
envsubst < test.properties > temp.properties
Undesired output:
bar
\\text\\word,bar
\\text2\\word2,bar
\\text3\\word3
Desired output:
bar\\text\\word,bar\\text2\\word2,bar\\text3\\word3
Was having a similar issue with a string in file where I need to replace something like this:
I managed to solve this protecting the variable name inside the string like this:
And then use the envsubst command normally. Hope it still helps you.