PDA

View Full Version : Very Useful, BUT its a Doubt



cavestine
10-15-2007, 05:16 AM
Hi folks,

I have some doubts regarding editing a file in Linux.

The problem is that, if my file consists something as




cavestine is a good boy
cavestine is studying in MIT
cavestine likes Kernel programming
cavestine is an active member of cprogramming.com forum.



Now in this file I want to remove "cavestine" by "mark"

Then I can open the file and use the following command to do so.




:%s/cavestine/mark/g



But the issue is if there are more than 1 file in a directory and I want to replace "cavestine" by "mark" in all files WITHOUT using any script, is there any such command to do so. I DONT want to open individual file and edit as above.

is "sed" the right command to use:)

thanx in advance:)

-- cavestine

CornedBee
10-15-2007, 06:14 AM
You could use sed in combination with find, or you could use a for loop on the command line.