Re: Search and Replace
On Fri, Jan 08, 1999 at 08:49:10AM -0700, John Greer wrote:
> I know that this is not Debian specific but I thought I would give it a
> shot anyway. I need to search a series of files for a text string
> (grep I know) and then I need to replace that string with another. Is
> there a command or string of commands that I can do this in? If
> this is possible it will make my life much easier!! Thanks
You can do what you want with sed or with a simple perl script.
Example:
sed s/oldstring/newstring/g <oldfile >newfile
If you have a lot of files to do,
for x in file1 file2 file3
do mv $x $x.old ; sed s/old/new/g <$x.old >$x ; done
You can use wildcards instead of file1...file3
Regards,
Jeff
Reply to: