From owner-freebsd-questions Tue Feb 5 13:34:51 2002 Delivered-To: freebsd-questions@freebsd.org Received: from hawk.mail.pas.earthlink.net (hawk.mail.pas.earthlink.net [207.217.120.22]) by hub.freebsd.org (Postfix) with ESMTP id 2CC9137B423 for ; Tue, 5 Feb 2002 13:34:46 -0800 (PST) Received: from user-2ivfotp.dialup.mindspring.com ([165.247.227.185] helo=gohan.cjclark.org) by hawk.mail.pas.earthlink.net with esmtp (Exim 3.33 #1) id 16YDEg-0006N8-00; Tue, 05 Feb 2002 13:34:44 -0800 Received: (from cjc@localhost) by gohan.cjclark.org (8.11.6/8.11.6) id g15LVhh01806; Tue, 5 Feb 2002 13:31:43 -0800 (PST) (envelope-from cjc) Date: Tue, 5 Feb 2002 13:31:43 -0800 From: "Crist J. Clark" To: Angela Yu Cc: freebsd-questions@FreeBSD.ORG Subject: Re: [Unix shell script] Message-ID: <20020205133143.C368@gohan.cjclark.org> Reply-To: cjclark@alum.mit.edu References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: ; from angelaoyu@hotmail.com on Tue, Feb 05, 2002 at 06:31:53PM +0000 X-URL: http://people.freebsd.org/~cjc/ Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Tue, Feb 05, 2002 at 06:31:53PM +0000, Angela Yu wrote: > Greetings. > > I am interested in knowing the shell script that can remove the subdomain > part of all FQDN in a input file, have domain name sorted and send the list > to a new output file. > > Example: > Input File - > www.hotmail.com > mail.yahoo.com > ftp.yahoo.com > mail.hotmail.com > www.computer.com.uk > > Output File- > computer.com.uk > hotmail.com > hotmail.com > yahoo.com > yahoo.com It's trivial with cut(1), sed(1), awk(1), and perl(1). But if you really want to use sh(1)... it is also trivial, for read HOST; do echo "${HOST#*.}" done < input.file -- Crist J. Clark | cjclark@alum.mit.edu | cjclark@jhu.edu http://people.freebsd.org/~cjc/ | cjc@freebsd.org To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message