lunedì 24 maggio 2010

Stat command in Perl (Unix/Linux)

This perl script execute a stat of a file in UNIX/LINUX environment and accept in input file name with absolute path. It shows various file info and atime, mtime and ctime.

#!/usr/bin/perl -w

#
# stat.pl
#

($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size,
$atime, $mtime, $ctime, $blksize, $blocks) = stat($ARGV[0]);

print("dev = $dev\n");
print("ino = $ino\n");
print("mode = $mode\n");
print("nlink = $nlink\n");
print("uid = $uid\n");
print("gid = $gid\n");
print("rdev = $rdev\n");
print("size = $size\n");
print("atime = $atime\n");
print("mtime = $mtime\n");
print("ctime = $ctime\n");
print("blksize = $blksize\n");
print("blocks = $blocks\n");
($sec, $min, $hr, $day, $month, $year, $day_Of_Week, $julianDate, $dst) = localtime($ctime);
$year = $year + 1900;
$month = $month + 1;
printf(" ctime $year/$month/$day $hr:$min:$sec\n");
($sec, $min, $hr, $day, $month, $year, $day_Of_Week, $julianDate, $dst) = localtime($mtime);
$year = $year + 1900;
$month = $month + 1;
printf(" mtime $year/$month/$day $hr:$min:$sec\n");
($sec, $min, $hr, $day, $month, $year, $day_Of_Week, $julianDate, $dst) = localtime($atime);
$year = $year + 1900;
$month = $month + 1;
printf(" atime $year/$month/$day $hr:$min:$sec\n");

Stay connected.


Nessun commento:

Posta un commento

Check Mid Year Objectives

Hi all Today middle year check of my 2026's goals. 1. ENGLISH Improve listening comprehension (So and So)   See at least one or two film...