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

How to get a particular string as your prompt ? Give syntax of that command?

3 Answers  


What does awk stand for?

0 Answers  


Write a command that will allow a unix system to shut down in 15 minutes, after which it will perform a reboot.

0 Answers  


How does a user get the current date, time in UNIX?

6 Answers   IBM,


What are awk commands?

0 Answers  






Write a command to kill the last background job?

0 Answers  


What is grep short for?

0 Answers  


what is the use of "test" command in unix?

4 Answers  


Can you write a command to erase all files in the current directory including all its sub-directories?

1 Answers  


what do you understand by 'unix is a portable os'?

3 Answers   Infosys,


What does mkdir up2date; touch outdated up2date do?

2 Answers  


What is command substitution?

0 Answers  


Categories