Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
add comment

1 Answer

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
1  
grep could do that too with grep -v -e END -e EXPDTA .... –  ott-- Oct 27 '11 at 15:27
1  
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
show 1 more comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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