From owner-freebsd-questions@FreeBSD.ORG Wed Jan 26 15:55:37 2005 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 2703A16A4CE for ; Wed, 26 Jan 2005 15:55:37 +0000 (GMT) Received: from mindfields.energyhq.es.eu.org (73.Red-213-97-200.pooles.rima-tde.net [213.97.200.73]) by mx1.FreeBSD.org (Postfix) with ESMTP id 64B3C43D5F for ; Wed, 26 Jan 2005 15:55:35 +0000 (GMT) (envelope-from flynn@energyhq.es.eu.org) Received: from scienide.energyhq.es.eu.org (scienide.energyhq.es.eu.org [192.168.100.1]) by mindfields.energyhq.es.eu.org (Postfix) with SMTP id DBDF83509A; Wed, 26 Jan 2005 16:55:33 +0100 (CET) Date: Wed, 26 Jan 2005 16:55:05 +0100 From: Miguel Mendez To: freebsd-questions@freebsd.org Message-Id: <20050126165505.06d2b3d4.flynn@energyhq.es.eu.org> In-Reply-To: <1878149195.20050126164325@wanadoo.fr> References: <1878149195.20050126164325@wanadoo.fr> X-Mailer: Sylpheed version 1.0.0-gtk2-20041224 (GTK+ 2.4.14; i386-portbld-freebsd5.3) Mime-Version: 1.0 Content-Type: multipart/signed; protocol="application/pgp-signature"; micalg="pgp-sha1"; boundary="Signature=_Wed__26_Jan_2005_16_55_05_+0100_Bk1J8V0aRUmswsoC" cc: atkielski.anthony@wanadoo.fr Subject: Re: One-line global string replace in all files with sed (or awk?) X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 26 Jan 2005 15:55:37 -0000 --Signature=_Wed__26_Jan_2005_16_55_05_+0100_Bk1J8V0aRUmswsoC Content-Type: text/plain; charset=US-ASCII Content-Disposition: inline Content-Transfer-Encoding: 7bit On Wed, 26 Jan 2005 16:43:25 +0100 Anthony Atkielski wrote: > A few years ago, I'm sure I came across a one-line way of replacing > every occurence of one string with another in an entire directory of > files (potentially including all subdirectories as well). I think it > used sed or awk. Now I can't find it. The examples on the Web are all > multiline scripts or programs, but I'm sure I saw a way to do it all on > just one line. > > Can anyone tell me how to do this? How about something like this (sh style)... for i in `find . -type f`; do sed -i -e 's/string1/string2/g' $i; done Cheers, -- Miguel Mendez http://www.energyhq.es.eu.org PGP Key: 0xDC8514F1 --Signature=_Wed__26_Jan_2005_16_55_05_+0100_Bk1J8V0aRUmswsoC Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (FreeBSD) iD8DBQFB971cnLctrNyFFPERAv0AAKCz5nE8Xtv4AkPV+uzW6ZyOQ3WrUQCghdqe A2DAKtznew3rZH0suiTDiA4= =PI8M -----END PGP SIGNATURE----- --Signature=_Wed__26_Jan_2005_16_55_05_+0100_Bk1J8V0aRUmswsoC--