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.

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.

share|improve this question
add comment

1 Answer

up vote 4 down vote accepted

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

share|improve this answer
add 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.