On Mon, Dec 19, 2005 at 03:38:23PM -0500, Tony Heal wrote: > I have a database name I want to replace inside of an xml file. I can do > this in several step using sed, but I would like to do it in a single step > using perl. This is what I have in sed and what does not work in perl. > > SED > #!/bin/bash > echo -n "Please enter the name of the new database: " > read syelledb > dbchange=`cat /tmp/data-sources.xml|grep database|cut -d ">" -f2|cut -d "<" > -f1` > sed s/$dbchange/$syelledb/ /tmp/data-sources.xml > /tmp/data-sources.xml.tmp > mv /tmp/data-sources.xml /tmp/data-sources.xml.orig > mv /tmp/data-sources.xml.tmp /tmp/data-sources.xml > > PERL (single line in bash script) > #!/bin/bash > echo -n "Please enter the name of the new database: " > read syelledb > > dbchange=`cat /tmp/data-sources.xml|grep database|cut -d ">" -f2|cut -d "<" > -f1` > /usr/bin/perl -pi -w -e 's/$dbchange/$syelledb/'
use double quotes: /usr/bin/perl -pi -w -e "s/$dbchange/$syelledb/" so the shell will interpolate the contents of the variables into the s/// expression (with single quotes you'd replace the literal string '$dbchange' by '$syelledb'...) Cheers, Almut -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]