I'm using grep to extract lines that match a regular expression. How to get only the matches and not the whole line?
Linux – `grep`-like utility to match strings instead of lines
greplinuxregex
greplinuxregex
I'm using grep to extract lines that match a regular expression. How to get only the matches and not the whole line?
Best Answer
You can supply grep the
-o
option. Like such:(Hint: The mnemonic I use for this is: omit everything except match)