Tuesday, June 1, 2010

time stamp of file create

SkyHi @ Tuesday, June 01, 2010
perl version for inodetime



Code:


<!--ntstart-->#!/usr/contrib/bin/<acronym title="Practical Extraction and Report Language">perl</acronym>
#^###################################################################
#^ $Header: inodetime.pl,v 1.1 97/01/20 10:17:00 http srvr? $
#^###################################################################
#^ PROGRAM DESCRIPTION
#^ -------------------
#^ This program prints the modification times and names of files.
#^ It uses the following format: inodetime.pl filename
#^ It will accept: inodetime.pl filename1 filename2 filename3
#^ inodetime.pl /tmp/file*
#^ The format of the output is: YYYYMMDDhhmmss filename
#^ example:
#^ $ inodetime.pl /tmp/t*
#^ 19961115105425 /tmp/test.sql
#^ 19970116113616 /tmp/tststat.pl
#^
#^ TRICK To Remember The Program Name
#^ ----------------------------------
#^ inodetime == I No De Time
#^ ^^ ^ ^
#^ KSG
#^###################################################################

############################################
# Get the (next) input from the command line
############################################
while ($curfile = $ARGV[0])
{
#################################################
# Do following code block only if $curfile exists
#################################################
if (-e $curfile)
{
###############################
# stat structure into variables
###############################
($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
$atime,$mtime,$ctime,$blksize,$blocks)
= stat("$curfile");
###############################
# time structure into variables
###############################
local($sec,$min,$hr,$day,$mon,$yr,$wday,@dntcare) = localtime($mtime);
$yr = ($yr>=70) ? $yr+1900 : $yr+2000;
$yr="$yr";
$mon = (++$mon < 10) ? "0$mon" : "$mon";
$day = ($day < 10) ? "0$day" : "$day";
$hr = ($hr < 10) ? "0$hr" : "$hr";
$min = ($min < 10) ? "0$min" : "$min";
$sec = ($sec < 10) ? "0$sec" : "$sec";
##################################################################
# Rearrange in the YYYYMMDDhhmmss format and assign to $dte variable
##################################################################
$dte = join('',$yr,$mon,$day,$hr,$min,$sec);
######################################
# Print modification date and filename
######################################
print ("$dte $curfile\n");
}
########################################
# Shift to next position in command line
########################################
shift (@ARGV);
}


#~###################################################################
#~###################################################################
#~
#~ $Log: inodetime.pl,v $
#~ Revision 1.1 97/01/20 10:17:00 10:17:00 http ()
#~ reversed output
#~ from: filename date
#~ to: date filename
#~
#~ Revision 1.0 97/01/17 12:37:32 12:37:32 http ()
#~ Initial revision
#~
#~###################################################################
#~###################################################################



REFERENCES
http://www.unix.com/unix-dummies-questions-answers/14206-time-stamp-file-create.html