From owner-freebsd-isp Tue Jan 7 17:46:50 1997 Return-Path: Received: (from root@localhost) by freefall.freebsd.org (8.8.4/8.8.4) id RAA04051 for isp-outgoing; Tue, 7 Jan 1997 17:46:50 -0800 (PST) Received: from hydrogen.nike.efn.org (resnet.uoregon.edu [128.223.170.28]) by freefall.freebsd.org (8.8.4/8.8.4) with ESMTP id RAA04035 for ; Tue, 7 Jan 1997 17:46:43 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by hydrogen.nike.efn.org (8.8.4/8.8.4) with SMTP id RAA03505; Tue, 7 Jan 1997 17:46:22 -0800 (PST) Date: Tue, 7 Jan 1997 17:46:22 -0800 (PST) From: John-Mark Gurney Reply-To: John-Mark Gurney To: rg@gds.de cc: freebsd-isp@freebsd.org Subject: Re: grep & replace In-Reply-To: <199701080055.BAA03700@gds.de> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-isp@freebsd.org X-Loop: FreeBSD.org Precedence: bulk On Wed, 8 Jan 1997 rg@gds.de wrote: > Hallo, > > I have to replace one special word in about one hundred files. The > expression could be several time in some files. > > Is there something like grep that would not only find these > expressions but also replace them by the new one? yep... it's sed: #!/bin/sh - for i in $*; do sed -e 's/word/newword/g' < $i > /tmp/$$.sed.out mv /tmp/$$.sed.out $i done that will replace all of `word' with `newword' in all the files listed on the command line.... hope this helps... ttyl.. John-Mark gurney_j@efn.org http://resnet.uoregon.edu/~gurney_j/ Modem/FAX: (541) 683-6954 (FreeBSD Box) Live in Peace, destroy Micro$oft, support free software, run FreeBSD (unix)