Date: Fri, 18 Feb 2005 13:05:58 -0500 From: Bill Moran <wmoran@potentialtech.com> Cc: freebsd-questions@freebsd.org Subject: Re: need help with script and sed Message-ID: <20050218130558.202a081b.wmoran@potentialtech.com> In-Reply-To: <42162874.6060304@tvog.net> References: <421622B0.9030600@ccstores.com> <42162874.6060304@tvog.net>
next in thread | previous in thread | raw e-mail | index | archive | help
--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 <laszlof@tvog.net> 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--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050218130558.202a081b.wmoran>