|
Alternative to perl search and replace
I'm writing a script and am trying to do a Perl search and replace in a file by replacing something in the file with a variable but it is turning the variable blank and replacing it with nothing. Here is the code:
perl -pi -e 's/hostname/$hostname/g' /etc/nagios/configs/$hostname/host.cfg
Is there another way to do this? Maybe sed?
Thank you for the help in advance.
|