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:
> 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

Good deal. Just remember to be careful about what you expand the
variable to since that has the potential to mess up the syntax of the
perl or sed command. For example, if $VAR has a / character in it
mayhem will ensue.

More information about expansion of variables should be available in
the man page for the shell you are using too.

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