TCLUG Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [TCLUG:10363] Using sed and evironmental variables



On Mon, Nov 22, 1999 at 04:01:24PM -0600, Bob Tanner wrote:
> Quoting Eric M. Hopper (hopper@omnifarious.mn.org):
> > 	You could try:
> > 
> > cat file | sed -e "s/FOO/$FOO/g"
> > 
> > 	Of course, if $FOO contains any '/'s or '\'s you still have
> > problems.
> > 
> > Have fun (if at all possible),
> 
> No, the double-quotes do not work. If I use double-quotes then it does not
> subsititue anything at all.

	That is very odd.  I tested that exact case with double quotes
and a file with lots of 'FOO's in it, and it worked fine.  Something
else you're doing is causing the double quotes to not work the expected
way.  Maybe your pattern has a '$' in it?

	You could try this:

cat file | sed -e 's/FOO/'"$FOO"'/g"

	Again, if $FOO has a '/' or '\' in it, it won't work right.

Have fun (if at all possible),
-- 
Its name is Public Opinion.  It is held in reverence. It settles everything.
Some think it is the voice of God.  Loyalty to petrified opinion never yet
broke a chain or freed a human soul.     ---Mark Twain
-- Eric Hopper (hopper@omnifarious.mn.org
                http://ehopper-host105.dsl.visi.com/~hopper) --