I want to use grep in the following way:

grep -v "END","EXPDTA" 1bmz_model1.pdb > 1bmz_model.pdb

I want the grep command to remove the lines which contain the words "END" and "EXPDTA", but all i get in the output, is a copy of the original file. The command works fine when I try to search and remove with a single word, but not with two words.

  • Is that really an AND or an OR? – Paul Oct 27 '11 at 12:15
egrep -v "END|EXPDTA" infile > outfile
  • 1
    Of course, if one is using egrep, one can fulfil the questioner's desire of removing lines with words that match, rather than everything that happens to have the three characters "END" within a larger word. ☺ – JdeBP Oct 27 '11 at 14:11
  • 4
    grep could do that too with grep -v -e END -e EXPDTA .... – ott-- Oct 27 '11 at 15:27
  • 2
    Could you provide some explanation about what your code does? – Tamara Wijsman Oct 31 '11 at 21:20
  • -v, --invert-match, Invert the sense of matching, to select non-matching lines. – Michael S. Feb 14 '12 at 11:24
  • 1
    man grep is your friend. – Michael S. Feb 14 '12 at 11:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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