From owner-freebsd-questions Tue Dec 18 3:27:34 2001 Delivered-To: freebsd-questions@freebsd.org Received: from freebie.atkielski.com (ASt-Lambert-101-2-1-14.abo.wanadoo.fr [193.251.59.14]) by hub.freebsd.org (Postfix) with ESMTP id D19AD37B41A for ; Tue, 18 Dec 2001 03:27:27 -0800 (PST) Received: from contactdish ([10.0.0.10]) by freebie.atkielski.com (8.11.3/8.11.3) with SMTP id fBIBOHR19620; Tue, 18 Dec 2001 12:24:17 +0100 (CET) (envelope-from anthony@freebie.atkielski.com) Message-ID: <009301c187b6$88994bf0$0a00000a@atkielski.com> From: "Anthony Atkielski" To: "Magnus B{ckstr|m" Cc: "FreeBSD Questions" References: Subject: Re: Command to make modifications on multiple files Date: Tue, 18 Dec 2001 12:24:18 +0100 Organization: Anthony's Home Page (development site) MIME-Version: 1.0 Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2600.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 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 Hmm ... I was kind of hoping for a single command that would do it for me, so I wouldn't have to debug something I'd write myself. However, I'll consider this, if I can't find anything ready-made. I'd prefer not to write a script of my own and discover a bug in it the hard way, which would mean a lot of restoring. ----- Original Message ----- From: "Magnus B{ckstr|m" To: "Anthony Atkielski" Cc: "FreeBSD Questions" Sent: Tuesday, December 18, 2001 11:50 Subject: Re: Command to make modifications on multiple files > 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 > To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message