Learn just a little Awk (2010)
Here is an Awk program (not a one-liner) that extracted select snippets of text from lots of docs and worked almost 10x faster than a grep equivalent:<p><pre><code>   awk &#x27;BEGIN { ORS=&quot; &quot;} { print $0 }&#x27; $2 | awk --re-interval -v pat=&quot;$1&quot; &#x27;
	{
            cut_content = substr($0, 1, match($0, &quot;==== Refs&quot;))
            orig_content = substr($0, 1, match($0, &quot;==== Refs&quot;))
            idx = 0
            regex = &quot;(^|[^a-zA-Z]{1})&quot; pat &quot;([^a-zA-Z]{1}|$)&quot;
            while (match(cut_content, regex)) {
              if (RLENGTH &gt; 0) {
                 prot = substr(cut_content, RSTART-1, RLENGTH+1)
                 gsub(&#x2F;[:punct: ]$&#x2F;, &quot;&quot;, prot)
                 gsub(&#x2F;^[:punct: ]&#x2F;, &quot;&quot;, prot)

                 print prot, &quot;\t&quot;, substr(orig_content, idx+RSTART-400, RLENGTH+800)
                 idx += (RSTART + RLENGTH -1)
                 cut_content = substr(cut_content, RSTART+RLENGTH)
              }
	    }
        }&#x27;</code></pre>