[conspire] can grep(1) print matching pattern rather than matching line?

Eric De Mund ead-cabal at ixian.com
Sat May 29 17:44:51 PDT 2004


Ladies and gentlemen,

------------------------------
QUESTION

How can I have grep(1) print out the matching pattern in a line
rather than that matching pattern's entire line?

------------------------------
BACKGROUND

I'm getting a lot of spam that's not getting caught by SpamAssassin.
Fortunately, the lion's share of that spam is addressed to the likes of:

    foo at ixian.com
    bar at ixian.com
    baz at ixian.com
    quux at ixian.com

I'd like to grep(1) through my (plaintext) VM INBOX file for all
instances of "@ixian.com" and print out not the lines that contain
"@ixian.com" but the matching patterns themselves, such as above. I plan
to take all of the above addresses and put them into my .procmailrc
file, for routing qualifying emails straight into the bitbucket.

Why don't I simply only retain email to:

    ead at ixian.com
    ead-*@ixian.com

, you ask? Well, because there are several other valid "@ixian.com"
email addresses besides hostmaster@ and postmaster@, that I both don't
recall at the moment, and, too, I'm not sure I could ever create a list
I'd be comfortable considering complete and definitive, for the purposes
of routing everything else into the bitbucket, sight unseen.

For simplicity's sake, I don't mind if this solution takes a line such
as:

    foo at ixian.com grow your automobile by 3 inches, naturally bar at ixian.com

and only returns:

    foo at ixian.com

rather than:

    foo at ixian.com
    bar at ixian.com

------------------------------

Is this possible? Or need I turn to perl(1) or python(1) for this? Much
obliged for any pointers.

Regards,
Eric
--
"All morning I worked on the proof of one of my poems, and took out a comma;
in the afternoon I put it back." --Oscar Wilde

Eric De Mund              |   Ixian Systems, Inc.   | cell: 650.303.4336
email: <ead at ixian.com>    | 650 Castro St, #120-210 |  fax: 240.282.4443
http://www.ixian.com/ead/ | Mountain View, CA 94041 | Y!IM: ead0002




More information about the conspire mailing list