Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

share|improve this question

1 Answer 1

up vote 2 down vote accepted

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

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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