Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

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 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
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
Could you provide some explanation about what your code does? – Tom Wijsman Oct 31 '11 at 21:20
-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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .