0

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

Duke
  • 1
  • 1

1 Answers1

0

Was having a similar issue with a string in file where I need to replace something like this:

my_string_$VAR_that_continues

I managed to solve this protecting the variable name inside the string like this:

my_string_${VAR}_that_continues

And then use the envsubst command normally. Hope it still helps you.