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

Re: OT: sed help



First, don't use 'test' as a filename -- it's confusing
because it's also a built in command in many shells.

Second, your shell script uses single quotes around the
sed script, which causes $VALUE1 and $VALUE2 *not* to be
expanded. Use double quotes in your shell script and
it should work.

	c

* James A. Peltier <james@site-fx.net> [020604 15:57]:
> sorry for this OT question regarding sed.
> 
> I'm trying to take command line user input and pipe it to sed for
> parsing.  currently i have this
> 
> 
> [joshua:] vi test
> #!/bin/sh
> VALUE1=$1
> VALUE2=$2
> 
> echo $VALUE1 $VALUE2 > text.tmp
> sed 's/$VALUE1/$VALUE2/' text.tmp > textfile
> 
> for some reason this doesn't work when I try
> 
> [joshua:] sh test test1 test2
> 
> any ideas why?  I'm certainly no sed expert as many can see.  What would
> be the easiest way to implement this?
> 
> - James