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

What is the behavioural difference between cmp and diff commands?

0 Answers  


Write a command that will display files in the current directory, in a colored, long format.

0 Answers  


how to remotely move a file ??? that mean how to move a file one machine to another machine ???

10 Answers   Altair,


distinguish between physical addresses and logical address?

3 Answers   Infosys,


solaris Run level?

3 Answers   Wipro,






What is the difference between udp and tcp?

2 Answers   HCL, TCS,


What do know about tee command and its usage?

0 Answers  


What is mtime in find command?

1 Answers  


How to get the last ten lines of a file using awk utility?

1 Answers   Infosys,


How does the system know where one command ends and another begins?

0 Answers  


How to check whether some services are running in another server or not? Suppose i am currently in a server named A.I want to check whether some services are running in server B without logging into the server B.

3 Answers   Amazon, MBA, Syntel, TCS, Unisys,


What do chown command do?

0 Answers  


Categories