|go ahead... be a heretic|
Search and replace within a fileby muizelaar (Sexton)
|on May 08, 2012 at 10:17 UTC||Need Help??|
muizelaar has asked for the
wisdom of the Perl Monks concerning the following question:
Got a problem which Iím not sure why itís happening and wondered if you could help?
I have written the code below to search the /etc/hosts file to search and replace all entries which have the host name and domain name suffix with what the user has input when the whole script has been run.
For example I want to change the below within the /etc/hosts file
My problem is that where I have placed the $uname (which is the uname Ėr output from the system) it is not being replaced. However where I have the domain name suffix part which is an actual name it does replace this and $uname replaces the server name after the FQN if you get what I mean.
Apologies if this is not clear it sounds ok in my head :-)
From the example above I get the following Servername.domainsuffix.org newname