From owner-freebsd-questions@FreeBSD.ORG Tue Dec 27 16:37:15 2005 Return-Path: X-Original-To: freebsd-questions@freebsd.org 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 BC40F16A41F for ; Tue, 27 Dec 2005 16:37:15 +0000 (GMT) (envelope-from mj001@rogers.com) Received: from smtp104.rog.mail.re2.yahoo.com (smtp104.rog.mail.re2.yahoo.com [206.190.36.82]) by mx1.FreeBSD.org (Postfix) with SMTP id 0969343D4C for ; Tue, 27 Dec 2005 16:37:14 +0000 (GMT) (envelope-from mj001@rogers.com) Received: (qmail 41896 invoked from network); 27 Dec 2005 16:37:14 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=rogers.com; h=Received:Subject:From:To:Cc:In-Reply-To:References:Content-Type:Date:Message-Id:Mime-Version:X-Mailer:Content-Transfer-Encoding; b=pSzJy03Y73pXdVXog2MRgUszFVvRsNISy/Hip8Fw7zHsWTXc47E9pURuaf1DrEUALtH0spMDZ/OmoXljfY6h9HEikfGVn9UUsWdB/rXAX4+9JrDkXZveJl8fQzQLHb0pnWJJTMyu9zDBRtcG5cJGTYgvEMmgi2jx8P98MA5GMHo= ; Received: from unknown (HELO chaucer.jeays.ca) (mj001@rogers.com@72.139.51.96 with plain) by smtp104.rog.mail.re2.yahoo.com with SMTP; 27 Dec 2005 16:37:13 -0000 From: Mike Jeays To: Jack Stone In-Reply-To: References: Content-Type: text/plain Date: Tue, 27 Dec 2005 11:37:11 -0500 Message-Id: <1135701431.2658.25.camel@chaucer.jeays.ca> Mime-Version: 1.0 X-Mailer: Evolution 2.2.1.1 FreeBSD GNOME Team Port Content-Transfer-Encoding: 7bit Cc: freebsd-questions@freebsd.org Subject: Re: a SED need X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 27 Dec 2005 16:37:15 -0000 On Tue, 2005-12-27 at 09:18 -0600, Jack Stone wrote: > I have some HTML files with hundreds of URLs that I need to modify using a > search/replace string. I assume that SED(1) is the right tool to use, but > every syntax I've tried has not worked. > > Here is what I'm trying to do: > Change full URLs to relative paths, in other words, chop off the > "http://www.example.com/" portion: > > >From this: >
  • > To this: >
  • > > I think it is the slashes and quotes that are giving me fits as I'm very > much a novice on SED(1) syntax. > > Would appreciate any tips on how to do the above so I can search and replace > all of the hundreds of URLs. > > Many thanks and Happy New Year! > > Regards, > Jack > > _________________________________________________________________ > Dont just search. Find. Check out the new MSN Search! > http://search.msn.click-url.com/go/onm00200636ave/direct/01/ > > _______________________________________________ > freebsd-questions@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-questions > To unsubscribe, send any mail to "freebsd-questions-unsubscribe@freebsd.org" sed will allow other characters than '/' as its delimiter, which makes it much easier to get escape sequences right, or avoid them altogether. sed -e 's=/http=/https=g' is an example