Script help using "cut"

antenneX antennex at swbell.net
Wed Aug 24 16:41:29 GMT 2005


----- Original Message ----- 
From: "Giorgos Keramidas" <keramida at ceid.upatras.gr>
To: "antenneX" <antennex at swbell.net>
Cc: <freebsd-questions at freebsd.org>
Sent: Wednesday, August 24, 2005 8:04 AM
Subject: Re: Script help using "cut"


> On 2005-08-24 07:58, antenneX <antennex at swbell.net> wrote:
> >"antenneX" <antennex at swbell.net> wrote:
> >>"Giorgos Keramidas" <keramida at ceid.upatras.gr> wrote:
> >>>>     (envelope-from spammer at badguy.com)
> >>>>     (envelope-from spammer2 at badguy2.com)
> >>>>     (envelope-from spammer3 at 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 at 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.




More information about the freebsd-questions mailing list