From owner-freebsd-questions@FreeBSD.ORG Tue Mar 7 14:12:16 2006 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 A185E16A420 for ; Tue, 7 Mar 2006 14:12:16 +0000 (GMT) (envelope-from xfb52@dial.pipex.com) Received: from asmtp-out6.blueyonder.co.uk (asmtp-out6.blueyonder.co.uk [195.188.213.65]) by mx1.FreeBSD.org (Postfix) with ESMTP id 16A1843D49 for ; Tue, 7 Mar 2006 14:12:13 +0000 (GMT) (envelope-from xfb52@dial.pipex.com) Received: from [62.31.10.79] (helo=[192.168.0.2]) by asmtp-out6.blueyonder.co.uk with esmtp (Exim 4.52) id 1FGcv5-0005o4-HT; Tue, 07 Mar 2006 14:12:11 +0000 Message-ID: <440D94BA.7040400@dial.pipex.com> Date: Tue, 07 Mar 2006 14:12:10 +0000 From: Alex Zbyslaw User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-GB; rv:1.7.12) Gecko/20060305 X-Accept-Language: en MIME-Version: 1.0 To: Bart Silverstrim References: <75a11e816bee8f2664ae1ccbd618dca7@athensasd.org> <551fa2ce1b8832dd3370d0e781c5b301@chrononomicon.com> In-Reply-To: <551fa2ce1b8832dd3370d0e781c5b301@chrononomicon.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable Cc: freebsd-questions Questions list Subject: Re: awk question 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, 07 Mar 2006 14:12:16 -0000 Bart Silverstrim wrote: > > On Mar 6, 2006, at 4:45 PM, Noel Jones wrote: > >> On 3/6/06, Bart Silverstrim wrote: >> >>> I'm totally drawing a blank on where to start out on this. >>> >>> If I have a list of URLs like >>> http://www.happymountain.com/archive/digest.gif >>> >>> How could I use Awk or Sed to strip everything after the .com? Or is= >>> there a "better" way to do it? =20 >> >> >> | cut -d / -f 1-3 > > > Oh boy was that one easy. It was a BAD mental hiccup. > > I'll add a sort and uniq and it should be all ready to go. =10Thanks! > More than one way to skin that cat! cut is nice'n'easy but since you=20 asked about awk and sed, these would work too: awk -F/ 'NF > 2 {printf "%s//%s\n", $1, $3}' or sed 's,^\([^/]*://[^/]*\).*,\1,' --Alex