Users of vi ..

Soldato
Joined
9 Dec 2004
Posts
5,701
Location
Dorset
I've got a mahooosive text file of some netware contexts and for each line I need to replace the root container. So for example;

bob.jimmy.centre

needs to be

bob.jimmy.newplace

(on around 2000 lines)

Its probably quite obvious but how can I do this in vi using a global replace command?

:%s/*.*.centre/*.*.newplace/g

Although thats absolute or whatever, so *.*.newplace does actually get pumped in.

Anyone got any ideas?

Thanks for your help.
 
U lost me abit
My linux pc in bits so i cant test your code
But could you not just cat your text file and pipe it to sed
Code:
cat old.txt | sed -e 's/centre/newplace/g'  > new.txt
 
depends on your what the rest of your data is like.

...but if they all contain jimmy then try...

:%s/jimmy.centre/jimmy.newplace/g

OR if you are certain that .centre only exists where you want to replace it then just do...

:%s/.centre/.newplace/g

Cheers.
 
Back
Top Bottom