On Thu, Nov 6, 2008 at 1:31 PM, Jay Hannah <span dir="ltr">&lt;<a href="mailto:jay@jays.net">jay@jays.net</a>&gt;</span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="Ih2E3d"><br></div>
Does this help?<br>
<br>
$ find ./ -name &quot;pat*&quot; | xargs ls -at | head -1<div><div></div><div class="Wj3C7c"><br>
</div></div></blockquote></div><br>It&#39;s ironic that you put that, since that&#39;s pretty much the exact command I&#39;m replacing. :)&nbsp; The problem is that one some of these systems &quot;ls&quot; is aliases to always put filesize in front (why?&nbsp; I don&#39;t know -- I find it annoying).<br>
<br>This is what I came up with after some googling and piecemailing.&nbsp; Anonymous subroutines are a good thing!<br><br>sub getLogFiles {<br><br><br>&nbsp; my ($logdir,$proc) = @_;<br><br>&nbsp; my @logfilelist =();<br><br>&nbsp; my %files={};<br>
<br>&nbsp; find(<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sub {<br>&nbsp;&nbsp;&nbsp; &nbsp;if (/^$proc/s) {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; my $filestats=stat($File::Find::name);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; $files{$File::Find::name}=$filestats-&gt;mtime;<br>&nbsp;&nbsp;&nbsp; &nbsp;}<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; },$logdir);<br><br>&nbsp; my $myfile= (sort{ $files{$a}&lt;=&gt;$files{$b} } keys %files)[-1];<br>
<br>&nbsp; return $myfile;<br><br>}<br>-- <br>Mike Hostetler<br><a href="http://mike.hostetlerhome.com/">http://mike.hostetlerhome.com/</a><br><br><br>