Re: Dateien eines Jahres finden

From: Joerg Wunsch <j(at)uriah.heep.sax.de>
Date: Sun, 3 Jun 2001 22:33:57 +0200

As Oliver Fromme wrote:

> Eine weitere Möglichkeit (Beispiel für das Jahr 1999):
>
> touch -t 199901010000 /tmp/1999.begin
> touch -t 200001010000 /tmp/1999.end
> find /foo/bar -newer /tmp/1999.begin '!' -newer /tmp/1999.end | ...

Wenn's nur um ein Verzeichnis und nicht eine ganze Hierarchie geht,
dann hilft auch (ja ich weiß, Olli, kannst Du nicht leiden :) ein
simpler Perlscript à la:

#!/usr/bin/perl

$d = "/usr/local/bin";
$year = 2001 - 1900; # localtime(3) has offset 1900

opendir(DIR, $d) || die "can't opendir $d: $!";

foreach $f (readdir(DIR)) {
    (@s = lstat "$d/$f") || die "can't stat $d/$d: $!";
    next unless -f _; # consider plain files only
    @t = localtime($s[9]); # $s[9] => mtime, $s[10] => ctime
    print "$f\n" if $t[5] == $year;
}

closedir DIR;

-- 
cheers, J"org               .-.-.   --... ...--   -.. .  DL8DTL
http://www.sax.de/~joerg/                        NIC: JW11-RIPE
Never trust an operating system you don't have sources for. ;-)
To Unsubscribe: send mail to majordomo(at)de.FreeBSD.org
with "unsubscribe de-bsd-questions" in the body of the message
Received on Sun 03 Jun 2001 - 22:50:21 CEST

search this site