Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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;;2;connection reset; try later;;3;spam message response; connection reset;;5;Deferred: lsjdflsdj; try later;, dsn=4.0.0, stat=Deferred: Connection reset by;4;Deferred: Connection reset by

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
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


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.