migrating server ips

Walter Dnes waltdnes-SLHPyeZ9y/tg9hUCZPvPmw at public.gmane.org
Tue Mar 10 02:15:54 UTC 2009


On Mon, Mar 09, 2009 at 06:22:09PM -0400, Teddy Mills wrote
> Need to migrate a server from 1 IP to another.
> There are a number of hardcoded IPs.
>
> Is there a global search and replace function?

  You can feed a script with commands to "ed" but any automated search
and replace is dangerous.  I would recommend using "grep" to spit out a
list of all occurences of the old IP address like so...

grep -R "111\.222\.333\.444" /etc/* > ip_list.txt

  Then go in and manually edit the files and occurences listed, after
confirming that it's OK to do so.

  A bit of unix trivia.  A long time ago, in a place not too far away,
Unix was rather primitive.  There was no grep command.  People would use
"ed" to list lines that matched certain criteria.  Using a text editor
to do straight listing can be dangerous, but that's all they had.  The
algorithm was to have "ed" go through the entire file, match a regular
expresion, and print all lines that matched.  The "ed" command to go
through a file is "g".  The short-hand notation for regular expression
is "re".  The print-to-stdout command is "p".  Put them all together,
and the shorthand notation is "g/re/p".  So guess what they called it
when someone wrote a read-only version of "ed", dedicated to listing
strings that match specified regular expressions?

-- 
Walter Dnes <waltdnes-SLHPyeZ9y/tg9hUCZPvPmw at public.gmane.org>
--
The Toronto Linux Users Group.      Meetings: http://gtalug.org/
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://gtalug.org/wiki/Mailing_lists





More information about the Legacy mailing list