Date: Tue, 11 Nov 1997 16:46:55 +0200 (IST) From: Eli Zaretskii To: Peter Palotas cc: djgpp AT delorie DOT com Subject: Re: Replace program? In-Reply-To: <3.0.16.19971111133622.ab9f3050@hem1.passagen.se> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Precedence: bulk On Tue, 11 Nov 1997, Peter Palotas wrote: > Is there a GNU util, which replaces words/phrases in text-files? Kind of > like grep but with a replacing option? Use Sed (v2gnu/sed118b.zip). It's a batch editor. For example, the following will replace "foo" with "fubar" in the file foo.txt and put it into fubar.txt: sed 's/foo/fubar/g' foo.txt > fubar.txt If you want to rewrite foo.txt itself, use `cat' (from Textutils, v2gnu/txt122b.zip), like this: cat foo.txt | sed 's/foo/fubar/g' > fubar.txt (When Sed is not given input files, it reads its stdin.) The quotes in the Sed command are only required if the text you are replacing includes whitespace.