I know that I can use
envsubst command to replace environment variables inside a file and write it to an output file:
envsubst < input.txt > output.txt
However, now I only have a variable and it's not a file. But I still need to replace any environment variable inside it.
export original_text="Hello $name, please come here $date" # I want to be able to replace $name and $date, in the RAM and not on disk and files export $name="John" export $date="tomorrow" output=$(envsubst < $original_text) # this is a pseudo-command echo $output # prints => Hello John, please come here tomorrow
Is it possible? How can do this?