Take the 2-minute tour ×

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.

share|improve this question
Is that really an AND or an OR? –  Paul Oct 27 '11 at 12:15

1 Answer 1

up vote 5 down vote accepted
egrep -v "END|EXPDTA" infile > outfile
share|improve this answer
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
grep could do that too with grep -v -e END -e EXPDTA .... –  ott-- Oct 27 '11 at 15:27
-v, --invert-match, Invert the sense of matching, to select non-matching lines. –  gentlesea Feb 14 '12 at 11:24
-e PATTERN, Use PATTERN as the pattern. This can be used to specify multiple search patterns, or to protect a pattern beginning with a hyphen (-). –  gentlesea Feb 14 '12 at 11:24

Your Answer


