You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
openwrt/openwrt/scripts/timestamp.pl

41 lines
649 B
Perl

#!/usr/bin/perl
use strict;
sub get_ts($) {
my $path = shift;
my $ts = 0;
open FIND, "find $path -not -path \\*.svn\\* -and -not -path \\*CVS\\* |";
while (<FIND>) {
open FILE, "<$_";
my @stat = stat FILE;
close FILE;
$ts = $stat[9] if ($stat[9] > $ts);
}
close FIND;
return $ts;
}
(@ARGV > 0) or push @ARGV, ".";
my $ts = 0;
my $n = ".";
my %options;
foreach my $path (@ARGV) {
if ($path =~ /^-/) {
$options{$path} = 1;
} else {
my $tmp = get_ts($path);
if ($tmp > $ts) {
$n = $path;
$ts = $tmp;
}
}
}
if ($options{"-p"}) {
print "$n\n";
} elsif ($options{"-t"}) {
print "$ts\n";
} else {
print "$n\t$ts\n";
}