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

Re: Clueless with sed



On Saturday 06 July 2002 17:56, Sean 'Shaleh' Perry wrote:
> On 06-Jul-2002 Joop Stakenborg wrote:
> > I am trying to get a sed script to behave nicely.....
> >
> > In a file (called 'config') with a line like:
> >      DEVEL_PREFIX = _ENVPATH_/$(TARGET_ARCH)-linux-uclibc
> > I would like to replace _ENVPATH_ with the current path, with the
> > following line: BASEDIR=`pwd`; sed 's/_ENVPATH_/$BASEDIR/g' config
> >
> > Here is the result:
> >      DEVEL_PREFIX = $BASEDIR/$(TARGET_ARCH)-linux-uclibc
> > Anyone have more experience with sed than I do?
>
> you used single quotes.  In shell '$foo' means exactly dollar sign f o o. 
> Use "$foo" and the variable will be interpreted.
>
> $ echo 'NAME said hi' | sed -e "s/NAME/$CVS_FULLNAME/"
> Sean 'Shaleh' Perry said hi
> $ echo 'NAME said hi' | sed -e 's/NAME/$CVS_FULLNAME/'
> $CVS_FULLNAME said hi

Your examples are okay, It seems I need to use double quotes...
However, it stil is wrong, when using:
BASEDIR=`pwd`; sed "s/_ENVPATH_/\$BASEDIR/g" config

I still get:
DEVEL_PREFIX = $BASEDIR/$(TARGET_ARCH)-linux-uclibc

Must have something to do with the way I use sed.
This seems to work (thanks to Eric Hanchrow <offby1@blarg.net>):
BASEDIR=`pwd`; sed "s,_ENVPATH_,$BASEDIR,g" config

Thanks everyone for responding, thanks Sean,

Joop


--
To UNSUBSCRIBE, email to debian-user-request@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org



Reply to: