Date: Wed, 24 Aug 2005 11:41:26 -0500 From: "antenneX" <antennex@swbell.net> To: "Giorgos Keramidas" <keramida@ceid.upatras.gr> Cc: freebsd-questions@freebsd.org Subject: Re: Script help using "cut" Message-ID: <000801c5a8ca$aca01680$0200000a@SAGEAME> References: <041801c5a84c$1a196560$0200000a@SAGEAME><042701c5a8ab$88debd60$0200000a@SAGEAME> <20050824130412.GB877@orion.daedalusnetworks.priv>
next in thread | previous in thread | raw e-mail | index | archive | help
----- Original Message -----
From: "Giorgos Keramidas" <keramida@ceid.upatras.gr>
To: "antenneX" <antennex@swbell.net>
Cc: <freebsd-questions@freebsd.org>
Sent: Wednesday, August 24, 2005 8:04 AM
Subject: Re: Script help using "cut"
> 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/'
>
In fact, my very next script line uses sed(1) to add the TAB and the
RHS to the sendmail access file:
sed 's/$/ REJECT/g' tmpfile >> /etc/mail/access
I'll bet my line could be incorporated with yours.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?000801c5a8ca$aca01680$0200000a>
