From owner-freebsd-questions Tue Dec 18 2:50:48 2001 Delivered-To: freebsd-questions@freebsd.org Received: from etek.chalmers.se (quarl0.etek.chalmers.se [129.16.32.20]) by hub.freebsd.org (Postfix) with ESMTP id EA9BE37B405 for ; Tue, 18 Dec 2001 02:50:45 -0800 (PST) Received: from downy.etek.chalmers.se (_7-268@downy.etek.chalmers.se [129.16.32.207]) by etek.chalmers.se (8.10.0/8.8.8) with ESMTP id fBIAoiM13810; Tue, 18 Dec 2001 11:50:44 +0100 (MET) Received: from localhost (b@localhost) by downy.etek.chalmers.se (8.10.0/8.10.0) with ESMTP id fBIAohg27353; Tue, 18 Dec 2001 11:50:43 +0100 (MET) Date: Tue, 18 Dec 2001 11:50:43 +0100 (MET) From: Magnus B{ckstr|m To: Anthony Atkielski Cc: FreeBSD Questions Subject: Re: Command to make modifications on multiple files In-Reply-To: <007701c187af$8b564d40$0a00000a@atkielski.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Tue, 18 Dec 2001, Anthony Atkielski wrote: > There is probably a UNIX command that allows me to replace strings in > multiple files all at once, but I can't remember what the name of it would > be, and this being UNIX, I'm sure the name is not the least bit intuitive. > Any suggestions on what command would do this? Sort of like grep, but with > an option to replace a string as well as just finding it. > Using bourne shell, something like for f in whatever/files/*.txt ; do sed -e 's/string to be replaced/new string/g' < ${f} > ${f}.tmp mv ${f}.tmp ${f} done // Magnus To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message