The `-o` option to `grep`

Published: Sun 11 April 2021
Updated: Sun 11 April 2021
By Greg Back

In linux.

I don't know how I made it this long in my technical career without knowing about the -o option to grep, which prints only the part of the line that matches the regular expression, not the entire line. I have spent way too much time post-processing the results with sed, awk, etc. (and learned a lot in the process), but hopefully this will save me (and you) some time in the future.

Source: grep(1) man page

links

social