Search and Repalce a particular word in VI Editor(UNIX)

While using VI editor in UNIX many of us come across a need to Replace a particular word with another word.
Say our file containing a text information as follows
"Ramu and giri are really nice friends. Both of them work in the same office. Ramu working as SWE and giri working as Accountant"
In the above text information if we want to replace all instances of the word Ramu with Krishna the following steps will help
Press Esc
give :
type like this

%s/Ramu/Krishna/g
or
1,$s/Ramu/Krishna/g

Some more similar tricks here
More about Vi


1 comments to "Search and Repalce a particular word in VI Editor(UNIX)"

Post a Comment

Who ever writes Inappropriate/Vulgar comments to context, generally want to be anonymous …So I hope U r not the one like that?
For lazy logs u can at least use Name/URL option which don’t even require any sign-in, good thing is that it can accept your lovely nick name also and URL is not mandatory too.
Thanks for your patience
~Krishna(I love "Transparency")
వీలయితే నాల్గు పోస్టులు ...కుదురితే ఒక కామెంటూ ...

Translate

Enter your email address:

Buffs ...

Visitors


hits counter
View My StatsCheck Google Page Rank

Add to Google Reader or Homepage

Bookmark and Share

Tags


Powered by WidgetsForFree

Archives