grep by default uses Basic Regular Expressions. This means the ( and ) lose their special meaning and are matched literally. Either use a backslash version \( to have a group, or use Extended Regular Expressions with -E "(IN|OUT)" . In man grep under REGULAR EXPRESSIONS are some differences noted.