On Fri, Mar 20, 2015 at 7:20 AM, Greg Wooledge <address@hidden> wrote:
> On Thu, Mar 19, 2015 at 06:37:30PM -0500, Peng Yu wrote:
>> The real problem is that I want to replace some bash variables in a
>> file and then print the output.
>
>http://mywiki.wooledge.org/TemplateFiles
The problem is that the variable must be exported to be usable. Is
there a way to somehow use the current shell?
~$ cat template.txt
$x $y
~$ cat main.sh
#!/usr/bin/env bash
export x=abc
export y=xyz
{
echo "cat <<EOF"
cat template.txt
echo "EOF"
} | bash
~$ ./main.sh
abc xyz
--
Regards,
Peng