How to replace the exact word in vi editor??
suppose a file contains words like amaze,amazed,amazement in
some of the line.But i want to replace only 'amaze' with
delight but don't wanna replace amazed or amazement.
thanks

Answers were Sorted based on User's Feedback



How to replace the exact word in vi editor?? suppose a file contains words like amaze,amazed,amazem..

Answer / shilpi gupta

sed 's/\<amaze\>/delight/g' file_name

or

In Vi editor..you can use

:%s/\<amaze\>/delight/g

Is This Answer Correct ?    7 Yes 0 No

How to replace the exact word in vi editor?? suppose a file contains words like amaze,amazed,amazem..

Answer / chandra babu.p

s/string/string/g;
ex;

:s/unix/linux/g

Is This Answer Correct ?    5 Yes 2 No

How to replace the exact word in vi editor?? suppose a file contains words like amaze,amazed,amazem..

Answer / majeed

First open the file by using vi editor and then

use this :%s /amaze/delight/g

Is This Answer Correct ?    3 Yes 2 No

How to replace the exact word in vi editor?? suppose a file contains words like amaze,amazed,amazem..

Answer / supreet goswami

sed-i "s| amaze |delight|g" filename

Is This Answer Correct ?    0 Yes 0 No

How to replace the exact word in vi editor?? suppose a file contains words like amaze,amazed,amazem..

Answer / kranthi kumar

:1,$s/amaze$/amazing/g

this will be changed only amaze in totalvi editor....

Is This Answer Correct ?    2 Yes 3 No

How to replace the exact word in vi editor?? suppose a file contains words like amaze,amazed,amazem..

Answer / ahmed

sed 's/amaze/amazing/g' filename.txt

Is This Answer Correct ?    0 Yes 1 No

Post New Answer

More Unix Commands Interview Questions

their is a file1,file2 and i want to append file1 data to file2?

9 Answers   IBM,


How would you find the size of a file or directory?

1 Answers  


What is the general format of unix command syntax?

2 Answers  


What is clustering in HP and how it's work?

1 Answers   HP,


In UNIX, what is the command to edit contents of the file?

9 Answers  






what is the command to print last 8 lines of any text file.

10 Answers  


What command is used to check the current users?

0 Answers  


what is virtual machine?

2 Answers   Infosys,


what are the different operating systems available?

3 Answers  


can we use cat command as an editor ..???

12 Answers   TCS,


What is grep r?

0 Answers  


What does sed command do in unix?

0 Answers  


Categories