i have a csv file which i need to filter mails marked with the word 'spam' lines look like this

email;text;somestatus;mailserver status response; response message
some@mail.com;mx.mail.com;2;connection reset; try later
thisspamshouldmatch@mail.com;somemx.record.com;3;spam message response; connection reset
thisshouldnotmatch@somedomain.net;spammxrecord.com;5;Deferred: lsjdflsdj; try later
shouldmatchspam@too.de;mx-too.de., dsn=4.0.0, stat=Deferred: Connection reset by mx-too.de.;4;Deferred: Connection reset by mx-too.de.

lines 3 and 5 should match

the pattern should match if in the first csv part (the chars until the first ';') contains the word 'spam' it shouldnt match if the word is within the other columns of the csv

i tried with

grep -e "spam[^;]*;\([^;]*;\)\{3\}"

anyone knows the solution? thx

link|improve this question

feedback

1 Answer

up vote 2 down vote accepted

Try grep -e "^[^;]*spam[^;]*;"

link|improve this answer
seems working thx – John Doe Jan 21 '10 at 12:38
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.