[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: (feature request) here-document, but from a file
From: |
William Park |
Subject: |
Re: (feature request) here-document, but from a file |
Date: |
Sat, 2 Jul 2005 21:06:22 -0400 |
User-agent: |
Mutt/1.4.2i |
On Sat, Jul 02, 2005 at 05:48:40PM -0600, Bob Proulx wrote:
> Chris F.A. Johnson wrote:
> > William Park wrote:
> > >It would be nice if I can read a file and process it as though it was
> > >here-document text in the script. Mainly, I want variable substitution,
> > >without calling lots of 'sed'.
> > >
> > >In Python, you would do
> > > print "..." % ...
> > >
> > >So, perhaps, you can use syntax like
> > > cat <<+ file
> > > cat <<<< file
> >
> > Why can't you use:
> >
> > cat < file
>
> The original poster said that the behavior wanted was variable
> substitution as in a here-document. Using 'cat < file' would not
> expand any variables.
>
> However counter proposals are useful. Will this work for you?
>
> eval echo $(<file)
>
> That will expand variables from the file using existing standard syntax.
If the file contains '<' or '>' (like HTML), then it will do
redirection. Probably, not good thing. :-)
--
William Park <opengeometry@yahoo.ca>, Toronto, Canada
ThinFlash: Linux thin-client on USB key (flash) drive
http://home.eol.ca/~parkw/thinflash.html
BashDiff: Super Bash shell
http://freshmeat.net/projects/bashdiff/