7

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.

1
  • Is that really an AND or an OR?
    – Paul
    Oct 27, 2011 at 12:15

1 Answer 1

9
egrep -v "END|EXPDTA" infile > outfile
7
  • 2
    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, 2011 at 14:11
  • 7
    grep could do that too with grep -v -e END -e EXPDTA ....
    – ott--
    Oct 27, 2011 at 15:27
  • 2
    Could you provide some explanation about what your code does? Oct 31, 2011 at 21:20
  • 1
    -v, --invert-match, Invert the sense of matching, to select non-matching lines.
    – Michael S.
    Feb 14, 2012 at 11:24
  • 1
    -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 (-).
    – Michael S.
    Feb 14, 2012 at 11:24

You must log in to answer this question.

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