Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 24 Aug 2005 16:04:12 +0300
From:      Giorgos Keramidas <keramida@ceid.upatras.gr>
To:        antenneX <antennex@swbell.net>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: Script help using "cut"
Message-ID:  <20050824130412.GB877@orion.daedalusnetworks.priv>
In-Reply-To: <042701c5a8ab$88debd60$0200000a@SAGEAME>
References:  <041801c5a84c$1a196560$0200000a@SAGEAME> <042701c5a8ab$88debd60$0200000a@SAGEAME>

next in thread | previous in thread | raw e-mail | index | archive | help
On 2005-08-24 07:58, antenneX <antennex@swbell.net> wrote:
>"antenneX" <antennex@swbell.net> wrote:
>>"Giorgos Keramidas" <keramida@ceid.upatras.gr> 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/'




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050824130412.GB877>