Global search and replace using Vi

Posted in dev-sys on April 28, 2006

to replace all instances of - say - 127.0.0.1 with 10.0.0.1 in a file then using vi you can do:

:%s/127.0.0.1/10.0.0.1/g

if you mess it up then press u for undo. Of course if it's an important file then back it up first.

Comments (0)