On Mon, Jan 08, 2001 at 12:56:45AM +0800, csj wrote: > Is there a tool to do a search-and-replace from the command line? > Something along the lines of: > > replace "string one" "string foo" files-to-process > > I find it a bit of a hassle to keep 100+ files open just to change an > ".html" to an ".htm." Note however that I intend to use the tool on > other text files besides runaway web pages, such as processing a list > of files to feed to tar. > Use something like
for file in * do sed 's/replace this/by this/g' < $file > $file.tmp; mv $file.tmp $file; done (there probably _are_ errors, check man sh) Miso&Frankie -- Nietzche is dead.
pgpNBNhYgG7XF.pgp
Description: PGP signature