From owner-freebsd-questions@FreeBSD.ORG Fri Feb 18 18:06:00 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 656E916A4CE for ; Fri, 18 Feb 2005 18:06:00 +0000 (GMT) Received: from internet.potentialtech.com (h-66-167-251-6.phlapafg.covad.net [66.167.251.6]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1306943D2F for ; Fri, 18 Feb 2005 18:06:00 +0000 (GMT) (envelope-from wmoran@potentialtech.com) Received: from localhost (pa-plum-cmts1e-68-68-113-64.pittpa.adelphia.net [68.68.113.64]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by internet.potentialtech.com (Postfix) with ESMTP id 4784369A71; Fri, 18 Feb 2005 13:05:59 -0500 (EST) Date: Fri, 18 Feb 2005 13:05:58 -0500 From: Bill Moran Message-Id: <20050218130558.202a081b.wmoran@potentialtech.com> In-Reply-To: <42162874.6060304@tvog.net> References: <421622B0.9030600@ccstores.com> <42162874.6060304@tvog.net> Organization: Potential Technologies X-Mailer: Sylpheed version 1.0.0rc (GTK+ 1.2.10; i386-portbld-freebsd5.3) Mime-Version: 1.0 Content-Type: multipart/signed; protocol="application/pgp-signature"; micalg="pgp-sha1"; boundary="Signature=_Fri__18_Feb_2005_13_05_58_-0500_IXgqqluKyz.F..6z" cc: fquest@ccstores.com cc: freebsd-questions@freebsd.org Subject: Re: need help with script and sed 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: Fri, 18 Feb 2005 18:06:00 -0000 --Signature=_Fri__18_Feb_2005_13_05_58_-0500_IXgqqluKyz.F..6z Content-Type: text/plain; charset=US-ASCII Content-Disposition: inline Content-Transfer-Encoding: 7bit Frank Laszlo wrote: > Jim Pazarena wrote: > > > I would like to traverse my /users/home tree searching > > for all regular files and change any lines which read: > > "/cgi-bin/Count.cgi ..." to: > > "http://counter.qcislands.net/cgi-bin/Count.cgi ..." > > > > I kinda think that a 'find' with an -exec of 'sed' would do > > it but I'm not sure, and even if it were, I'm not sure of > > the syntax. > > > > Could someone help me please? > > > > Thanks! > > Jim > > > > for i in `find /users/home -type f`; do > sed -i '' > "s|/cgi-bin/Count.cgi|http://counter.qcislands.net/cgi-bin/Count.cgi|g" $i > done The only thing I would recommend different is to provide a backup file extension to the -i option of sed. That way it keeps a copy of the file as it was before sed touches it. This will save you a lot of headaches, if sed does something you don't expect. -- Bill Moran Potential Technologies http://www.potentialtech.com --Signature=_Fri__18_Feb_2005_13_05_58_-0500_IXgqqluKyz.F..6z Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (FreeBSD) iD8DBQFCFi6GYOm/CGAEZUARAturAKC+XN9ohAoF7AZ8TFeUQJ7VRpp52wCdE/cx yZElSdXYfhAQ2a1sqFu/O+g= =sEFt -----END PGP SIGNATURE----- --Signature=_Fri__18_Feb_2005_13_05_58_-0500_IXgqqluKyz.F..6z--