I am trying to find data from files using grep, but grep usually prints out the filename as well as the line where the term is found.

In this case, I am looking for a special regexp and I want grep to print all items matching the regexp, not the line or the filename. In other words, I want to see only the matched regular expression.

1 Answer 1


With GNU grep, that's the -o option possibly combined with -h to suppress the filename.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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