Finding ctime, atime and mtime

From: lawries@btinternet.com
Date: Fri Nov 21 2003 - 10:07:02 EST


Admins,

I had a requirement to list out all the time stamps
on files in a directory and thought I would share the solution.

A very quick and dirty perl script.

#!/usr/bin/perl -w
##############################################################################
# #
# FILE NAME: ftime #
# #
#----------------------------------------------------------------------------#
# PURPOSE: Retrive full set of file date #
# #
#----------------------------------------------------------------------------#
# usage: #
# List of files piped into ftime #
# #
# example: #
# #
# ls -l | awk '{ print $9 }' | /usr/local/bin/ftime #
# #
#----------------------------------------------------------------------------#
# REVISIONS: #
# #
# Lawrie November 2003 #
##############################################################################

use strict;
# use File::stat;

  while (<>) {

        chomp($_);
        my($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size, $atime, $mtime,
           $ctime, $blksize, $blocks) = stat($_);

        my $access = localtime $atime;
        my $modify = localtime $mtime;
        my $inodes = localtime $ctime;

        printf "$_ : \n";
        printf " Last Access Time : $access \n";
        printf " Last Modify Time : $modify \n";
        printf " Last Inode change: $inodes \n";

  }

Lawrie



This archive was generated by hypermail 2.1.7 : Sat Apr 12 2008 - 10:49:44 EDT