<div dir="ltr">I know grep gives you the lines and line numbers <div><br></div><div>  grep jacoby -sil *<br><br>But what if you wanted to match them and just them? Like, for example, you wanted to pull all the perl scripts out of your crontab?<br><br>crontab -l | match -r '([\w\.\/]*.pl)'<br><br>Which you can then sort or sort -u to just see those files.<br><br><div style="color:rgb(0,0,0);font-family:"Fira Code","Droid Sans Mono Slashed",monospace;font-size:12px;line-height:16px;white-space:pre"><div><span style="color:rgb(0,128,0)">#!/usr/bin/env perl</span></div><br><div><span style="color:rgb(175,0,219)">use</span> strict ;</div><div><span style="color:rgb(175,0,219)">use</span> warnings ;</div><div><span style="color:rgb(175,0,219)">use</span> utf8 ;</div><div><span style="color:rgb(175,0,219)">use</span> feature <span style="color:rgb(163,21,21)">qw{ postderef say signatures state }</span> ;</div><div><span style="color:rgb(121,94,38)">no</span> warnings <span style="color:rgb(163,21,21)">qw{ experimental::postderef experimental::signatures }</span> ;</div><br><div><span style="color:rgb(175,0,219)">use</span> Getopt::Long ;</div><br><div><span style="color:rgb(0,0,255)">my</span> <span style="color:rgb(0,16,128)">$regex</span> ;</div><div>GetOptions(</div><div>    <span style="color:rgb(163,21,21)">'regex=s'</span> => \<span style="color:rgb(0,16,128)">$regex</span> </div><div>);</div><div><span style="color:rgb(175,0,219)">exit</span> <span style="color:rgb(175,0,219)">unless</span> <span style="color:rgb(121,94,38)">defined</span> <span style="color:rgb(0,16,128)">$regex</span>;</div><br><div><span style="color:rgb(0,0,255)">my</span> <span style="color:rgb(0,16,128)">@output</span>;</div><div><span style="color:rgb(175,0,219)">while</span> (<<span style="color:rgb(121,94,38)">STDIN</span>>) {</div><div>    <span style="color:rgb(121,94,38)">push</span> <span style="color:rgb(0,16,128)">@output</span> , <span style="color:rgb(0,16,128)">$_</span> =~ <span style="color:rgb(121,94,38)">m</span><span style="color:rgb(129,31,63)">{</span><span style="color:rgb(0,16,128)">$regex</span><span style="color:rgb(129,31,63)">}</span><span style="color:rgb(175,0,219)">gmix</span>;</div><div>}</div><div><span style="color:rgb(121,94,38)">say</span> <span style="color:rgb(121,94,38)">join</span> <span style="color:rgb(163,21,21)">"</span><span style="color:rgb(255,0,0)">\n</span><span style="color:rgb(163,21,21)">"</span>, <span style="color:rgb(0,16,128)">@output</span>;</div><br></div><div><br></div><div>If there's a regular thing and I just never learned the right Unix-fu, I'd love to know.</div><div><br></div>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div>Dave Jacoby<br>
<a href="mailto:jacoby.david@gmail.com" target="_blank">jacoby.david@gmail.com</a><br>
<br>Don't panic when the crisis is happening, or you won't enjoy it.</div></div></div></div></div>