grep -o

If only one could know which skills will be worth learning! The time I invested in learning about APL, Ada, Cobol, RSX/11, Focal, Snobol, 6809 assembler, etc. etc. didn’t return much value beyond amusement, entertainment, and experiance.

Learning all the Unix tools back in 1977 was fun too it has been extremely valuable too!

Sometimes I discover that since then somebody has added a new tool; or a new switch to existing one. Today I learned about the -o switch to grep. It prints out only the matching string; not the whole line.


536$ grep -o '[a-z][a-z]*:[a-z][a-z]*' cascades.rdf | sort | uniq
foaf:name
my:author
my:editor
ow:address
ow:author
ow:booktitle
ow:editor
ow:institution
ow:journal
ow:month
...

Useful.

0 thoughts on “grep -o

  1. James

    Add
    export GREP_OPTIONS=–color=auto
    to your startup scripts and grep will highlight matches (in red by default)

Leave a Reply

Your email address will not be published. Required fields are marked *