I'm trying to use an output of a pipe as a variable that I'll pass to sed  to search and replace in file.
The contents of my .env file is
TEST=bla
TEST_2=blabla
and I want to replace %TEST% in my config.txt file
This is some fake config file. The value of test variable is %TEST%.
After replacement, this statement should be
This is some fake config file. The value of test variable is bla.
I've tried
grep 'TEST=' .env | sed 's/^.*=//' |  sed -i '' 's|%TEST%|$1|g' config.txt
But the result is
This is some fake config file. The value of test variable is $1.
How do I capture and use the output of a previous pipe in sed?
 
    