Thread Datei-Datum ermitteln
(2 answers)
Opened by crojay at 2011-08-24 01:16
Meinst du die Zeit der Letzten Veränderung ("mtime")?
Code (perl): (dl
)
1 2 3 4 5 6 7 8 9 10 #!/usr/bin/perl use POSIX; use strict; use warnings; my $file=shift(@ARGV) // '/etc/fstab'; my $timestr=POSIX::strftime( "%Y-%m-%d_%H:%M:%S", localtime(( stat $file )[9] ) ); print "$timestr\n"; Das kann man auch von Hand: Code (perl): (dl
)
1 2 3 4 5 6 7 8 9 10 11 12 #!/usr/bin/perl use strict; use warnings; my $file=shift(@ARGV) // '/etc/fstab'; my @date=reverse((localtime(( stat $file )[9] ))[0..5]); $date[0]+=1900; $date[1]+=1; my $timestr=sprintf('%04u-%02u-%02u_%02u:%02u:%02u',@date); print "$timestr\n"; Last edited: 2011-08-24 03:57:52 +0200 (CEST) |