10

I'm using grep to extract lines that match a regular expression. How to get only the matches and not the whole line?

0

1 Answer 1

18

You can supply grep the -o option. Like such:

grep -o pattern file

(Hint: The mnemonic I use for this is: omit everything except match)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .