[Cialug] SED replace IP help

chris129 at cs.iastate.edu chris129 at cs.iastate.edu
Fri Sep 22 14:41:27 CDT 2006


I'd be terribly hesitant to give an exact command for that.  But you should look
at sed's man page under option "-e".  Something like:
sed -e 's/oldip/newip/g' -i filename

The -i is the dangerous part, it makes it go in place.  So, if you remove the -i
you can do this:
sed -e 's/oldip/newip/g' | less
Then manually see if it hasn't butchered your whole file.

I hope someone else will post something more reliable than this, but you can
hopefully work from there.  The danger here is if "oldip" is a part of
something totally unrelated to the ip number (pretty off chance, but who
knows), sed would still do the switch.

As far as searching the complete drive that sounds like a real ugly idea.  But
you could do this:
find / -name "*"  -exec grep oldip -l {} \;

That should list out the possibly relevant files.  

I'm sure I don't have to tell you to be careful.  sed -i can damage a file if
you don't have a regexp that's what you needed.

Quoting Adk <adk at 52761.com>:

> Our local group has a server for our list and a couple of non-profits.
> Local ISP just upgraded one of their routers and now we have lost
> the IP that their DHCP was handing out. It had been a workable situation
> before and IP never changed unless they made an equipment change.
> We have no money to purchase a static IP- $120/yr.
> 
> We are running DNS, Web, and mail on the box.
> 
> Can I use sed to search the complete drive and replace the IP?
> What would be the exact command?
> 
> Our local guru help is out of town and we need to get this box up soon.
> 
> Allen Kiddoo
> Muscatine
> 
> ________________________________________________
> VHCS Webmail
> 
> 
> _______________________________________________
> Cialug mailing list
> Cialug at cialug.org
> http://cialug.org/mailman/listinfo/cialug
> 





More information about the Cialug mailing list