string replacement doesn't work with a variable
inode0
inode0 at gmail.com
Thu Feb 9 14:33:01 UTC 2006
On 2/9/06, Marcel Fritzenwallner <linux at fritzenwallner.org> 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
More information about the redhat-list
mailing list