Sunday, August 2, 2009

How to interchange the letters in the unix. ex - MURALI is a word and now I want to interchange U and R.How?

Suppose there is file in unix like this





MURALI IS A GODO BOY.


MURALI IS A GODO BOY.


MURALI IS A GODO BOY.


MURALI IS A GODO BOY.


MURALI IS A GODO BOY.


MURALI IS A GODO BOY.


...............


..............


..............


..............





Now this file is having some thousand lines and each line ther e is a mistake in the spelling GOOD. Now what is the command in unix to inter change the letters in UNIX. Pls help me.

How to interchange the letters in the unix. ex - MURALI is a word and now I want to interchange U and R.How?
Use the sed command


sed 's\GODO\GOOD\' file %26gt;file
Reply:Vi and sed ways already covered.





Here is my bit if you are by any chance, an Emacs user.





open that file in Emacs, press Alt key, and press 'x' while Alt is still pressed. You will get a prompt like M-x in the minibuffer. There, type query-replace and press the enter key.





You will be prompted for the string to look for. Enter GODO there. press enter.





You will be prompted for the string to replace with. Enter GOOD and press enter.





You will be presented with options like replace all, replace, cancel, replace and quit, quit. Choose one to your content and you are done!





Trust me, it looks long, but you will be stupefied to see hoe easy and versatile it is. When you grow fluent with Emacs, you will find that this is a trivial work that Emacs can do.





hmm, a bit of marketing there for Emacs, eh? ;)
Reply:Learn English and Write the Whole Document Without any Mistakes, ;) I think This solves your problem
Reply:If you know vi editor means,





Open the file in the editor


Type the following in the after pressing shift + :





g/godo/s//good/g


No comments:

Post a Comment