I'm using grep to extract lines that match a regular expression. How to get only the matches and not the whole line?
1 Answer
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)