Linux下计算文件的MD5值
2012-11-28 15:30:15 来源:WEB开发网核心提示:close FH; return $filemd5; } #获取文件的atime,mtime,ctime sub getFileAMCTime { $filename = shift @_; my ($atime,$mtime ,$ctime) = (stat ($filename))[8,9,10]; $atime
close FH;
return $filemd5;
}
#获取文件的atime,mtime,ctime
sub getFileAMCTime {
$filename = shift @_;
my ($atime,$mtime ,$ctime) = (stat ($filename))[8,9,10];
$atime = &getTime($atime);
$mtime = &getTime($mtime);
$ctime = &getTime($ctime);
#将日期时间格式转换为比较友好的格式
sub getTime {
my $time = shift @_;
my($sec,$min,$hour,$day,$mon,$year) = (localtime $time)[0..5];
$time = sprintf "%4d-%02d-%02d %2d:%02d:%02d",$year + 1900,$mon + 1,$day,$hour,$min,$sec;
return $time;
}
return $atime,$mtime,$ctime;
}
return $filemd5;
}
#获取文件的atime,mtime,ctime
sub getFileAMCTime {
$filename = shift @_;
my ($atime,$mtime ,$ctime) = (stat ($filename))[8,9,10];
$atime = &getTime($atime);
$mtime = &getTime($mtime);
$ctime = &getTime($ctime);
#将日期时间格式转换为比较友好的格式
sub getTime {
my $time = shift @_;
my($sec,$min,$hour,$day,$mon,$year) = (localtime $time)[0..5];
$time = sprintf "%4d-%02d-%02d %2d:%02d:%02d",$year + 1900,$mon + 1,$day,$hour,$min,$sec;
return $time;
}
return $atime,$mtime,$ctime;
}
更多精彩
赞助商链接