I'm trying to use bash's envsubst to substitute an environment variable into a file. Here's a simple example that fails to work as expected:
Create a file with a variable substitution in it:
echo 'Filename: ${FILE}' > test.txt
Now try to use envsubst in a for loop:
for FILE in `ls`; do envsubst < test.txt; done
Filename:
The result is just Filename: the substitution fails.
Echo works as expected in this context:
for FILE in `ls`; do echo Filename: ${FILE}; done
Filename: test.txt
I don't understand why echo would work and envsubst would fail.