Script help using "cut"

Giorgos Keramidas keramida at
Wed Aug 24 13:04:22 GMT 2005

On 2005-08-24 07:58, antenneX <antennex at> wrote:
>"antenneX" <antennex at> wrote:
>>"Giorgos Keramidas" <keramida at> wrote:
>>>>     (envelope-from spammer at
>>>>     (envelope-from spammer2 at
>>>>     (envelope-from spammer3 at
>>>> 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 I need the result
> 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