Browse Source

Tool for running a command on the newest non-directory

Example: run_match_latest.pl gdb

will run gdb on the latest non-directory file in the current directory, which
is hopefully a core file.
master
Duke Leto 14 years ago
parent
commit
67de09d00b
  1. 15
      bin/run_match_latest.pl

15
bin/run_match_latest.pl

@ -0,0 +1,15 @@
#!/usr/bin/perl -w
# Run a given program on the newest non-directory in a given directory
use strict;
$|++;
my $program = shift || die "Must give program to run with latest file";
my $dir = shift || './';
opendir (my $d, $dir) or die $!;
my @files = sort { -M $b <=> -M $a } grep { !-d $_ } readdir ($d);
print "Running: $program " . $files[-1] . "\n";
system($program, $files[-1]);
closedir ($d);
Loading…
Cancel
Save