help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-bash] bash variable interpolation


From: Peng Yu
Subject: Re: [Help-bash] bash variable interpolation
Date: Fri, 20 Mar 2015 21:39:24 -0500

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]