Grep command, to remove lines containing a specified word

6

1

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.

Harpal

Posted 2011-10-27T12:04:40.087

Reputation: 195

Is that really an AND or an OR? – Paul – 2011-10-27T12:15:18.353

Answers

7

egrep -v "END|EXPDTA" infile > outfile

kek

Posted 2011-10-27T12:04:40.087

Reputation: 283

2Of 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 – 2011-10-27T14:11:17.237

5grep could do that too with grep -v -e END -e EXPDTA .... – ott-- – 2011-10-27T15:27:30.437

2Could you provide some explanation about what your code does? – Tamara Wijsman – 2011-10-31T21:20:34.163

1-v, --invert-match, Invert the sense of matching, to select non-matching lines. – Michael S. – 2012-02-14T11:24:26.460

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. – 2012-02-14T11:24:51.453

1man grep is your friend. – Michael S. – 2012-02-14T11:25:46.973