string replacement doesn't work with a variable
Marcel Fritzenwallner
linux at fritzenwallner.org
Thu Feb 9 14:19:20 UTC 2006
Thanks a lot!
This little thing cost me many hours, now it's working even with "sed":
sed -i "s/ABC/$VAR/" file.txt
perl -pi'.bak' -e "s/ABC/$VAR/g" file.txt
Marcel
Quoting inode0 <inode0 at gmail.com>:
> On 2/9/06, Marcel Fritzenwallner <linux at fritzenwallner.org> wrote:
> > Hi,
> >
> > I want to replace a string in a file, the problem is that the replacement
> is a
> > variable, and this doesn't work. I could not get it working with sed nor
> with perl.
> >
> > Can anyone help me?
> > -----------------------------------------
> > perl -pi'.bak' -e 's/ABC/$VAR/g' file.txt
> > -----------------------------------------
>
> Try
>
> perl -pi'.bak' -e "s/ABC/$VAR/g" file.txt
>
> instead. Double quotes allow the expansion of $VAR to occur.
>
> John
>
> --
> redhat-list mailing list
> unsubscribe mailto:redhat-list-request at redhat.com?subject=unsubscribe
> https://www.redhat.com/mailman/listinfo/redhat-list
>
More information about the redhat-list
mailing list