From owner-freebsd-questions@FreeBSD.ORG Wed Aug 24 13:04:22 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 4DA6D16A41F for ; Wed, 24 Aug 2005 13:04:22 +0000 (GMT) (envelope-from keramida@ceid.upatras.gr) Received: from aiolos.otenet.gr (aiolos.otenet.gr [195.170.0.93]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8427743D64 for ; Wed, 24 Aug 2005 13:04:15 +0000 (GMT) (envelope-from keramida@ceid.upatras.gr) Received: from orion.daedalusnetworks.priv (aris.bedc.ondsl.gr [62.103.39.226]) by aiolos.otenet.gr (8.13.4/8.13.4/Debian-1) with SMTP id j7OD4DSM028769; Wed, 24 Aug 2005 16:04:13 +0300 Received: from orion.daedalusnetworks.priv (orion [127.0.0.1]) by orion.daedalusnetworks.priv (8.13.4/8.13.4) with ESMTP id j7OD4CpF001280; Wed, 24 Aug 2005 16:04:12 +0300 (EEST) (envelope-from keramida@ceid.upatras.gr) Received: (from keramida@localhost) by orion.daedalusnetworks.priv (8.13.4/8.13.4/Submit) id j7OD4Chk001279; Wed, 24 Aug 2005 16:04:12 +0300 (EEST) (envelope-from keramida@ceid.upatras.gr) X-Authentication-Warning: orion.daedalusnetworks.priv: keramida set sender to keramida@ceid.upatras.gr using -f Date: Wed, 24 Aug 2005 16:04:12 +0300 From: Giorgos Keramidas To: antenneX Message-ID: <20050824130412.GB877@orion.daedalusnetworks.priv> References: <041801c5a84c$1a196560$0200000a@SAGEAME> <042701c5a8ab$88debd60$0200000a@SAGEAME> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <042701c5a8ab$88debd60$0200000a@SAGEAME> Cc: freebsd-questions@freebsd.org Subject: Re: Script help using "cut" 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: Wed, 24 Aug 2005 13:04:22 -0000 On 2005-08-24 07:58, antenneX wrote: >"antenneX" wrote: >>"Giorgos Keramidas" wrote: >>>> (envelope-from spammer@badguy.com) >>>> (envelope-from spammer2@badguy2.com) >>>> (envelope-from spammer3@badguy3.com) >>>> >>>> All ideas appreciated.... >>> >>> $ awk '{print $2}' tmpfile | sed -e 's/)[[:space:]]*$//' | sort | uniq > > Just woke up this morning and realized I needed to chop off more -- > everything except the domain. > > So, instead of spammer@badguy.com I need the result badguy.com > > How could the above awk line be expanded to chop off the username@ > portion as well? sed(1) can do more than one substitutions in one line: sed -e 's/)[[:space:]]*$//' -e 's/^.*@//' or you can use as complex regular expressions as necessary to cut specific parts of the line: sed -e 's/^.*@\([^)]*\))[[:space:]]*$/\1/'