Script help using "cut"
Giorgos Keramidas
keramida at ceid.upatras.gr
Wed Aug 24 13:04:22 GMT 2005
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/'
More information about the freebsd-questions
mailing list