Hero search

grep -hERo pulls only the matching substring from a recursive search — and since the flags spell it out, I'm calling it a hero search.

Have you ever hero searched? Let’s have a look at some grep options.

Whack’em together, and you get -ERho. Or, well, -hoRE. No, wait. -hERo! I dub thee “hero search” (mmm, mnemonics)!

Case in point: quick and dirty statistics of character entities in a directory of 500 sgml files:

$ grep -hERo '&[^;]+;' /path/to/files | sort | uniq -c | sort -nr
     64 č
     30 ř
     24 ě
     ...