Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

This question already has an answer here:

How would I display the lines that do not contain certain letters? This is what I have already tried unsuccessfully to show the lines that do not consist of an a or b:

egrep *[^ab]* filename
share|improve this question

marked as duplicate by Radu Rădeanu, Warren Hill, guntbert, Eric Carvalho, Thomas W. Sep 29 '13 at 18:17

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
You have this answer in one of the comments on a previous answer to another question of yours. You should read them! Also see man grep; it can learn you a lot. –  Radu Rădeanu Sep 29 '13 at 6:38
add comment

1 Answer 1

Just use invert matching:

grep -v "[ab]" filename

Source: man page for grep

share|improve this answer
    
Don't forget to quote the pattern to grep. If the current directory happens to have the two files named a and b, the command will turn into grep -v a b filename, which does something different than intended. So: grep -v '[ab]' filename –  geirha Sep 29 '13 at 10:38
    
@geirha: Oh yes, thanks! –  i08in Sep 29 '13 at 10:39
add comment

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