Re: string replacement doesn't work with a variable

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

 



On 2/9/06, Marcel Fritzenwallner <linux@xxxxxxxxxxxxxxxxxx> 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@xxxxxxxxxx?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/redhat-list

[Index of Archives]     [CentOS]     [Kernel Development]     [PAM]     [Fedora Users]     [Red Hat Development]     [Big List of Linux Books]     [Linux Admin]     [Gimp]     [Asterisk PBX]     [Yosemite News]     [Red Hat Crash Utility]


  Powered by Linux