Sponsored Content
Top Forums Shell Programming and Scripting Finding out the last modified time for files Post 86942 by jim mcnamara on Tuesday 18th of October 2005 02:11:30 PM
Old 10-18-2005
Otherwise you'll have to use perl or something similar to get a full filetime - this gets the mtime of the file:
Code:
#!/usr/bin/perl
#^ PROGRAM DESCRIPTION
#^ -------------------
#^ This program prints the modification times 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:
#^           $ filetime.pl /tmp/t*
#^           19961115105425 /tmp/test.sql
#^           19970116113616 /tmp/tststat.pl
#^

############################################
# 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\n");
      }

   # Shift to next position in command line

   shift (@ARGV);
}

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Checking modified time of files

My problem is with the find command. After looking through the forum I've got - find . -mtime 2 -name "*" which gives me a list of all the files modified in the last 2 days. How do I change this to list files modified in the last 2 hours? Sorry if this question is already on the forum... (4 Replies)
Discussion started by: am97395331
4 Replies

2. UNIX for Dummies Questions & Answers

Finding modified files

Last week I was using the command: ' find /directory -mtime -2 -print' and it showed all the files modified within that period. However, now it only displays the directories and not the files modified. The only thing that changed is that I was granted access to some files. Thanks (2 Replies)
Discussion started by: rhayabusa
2 Replies

3. Solaris

Finding list of modified files for a particular time duration

Hi , I am trying to find out the List of files modified or added aftter installation of any component on SUN solaris box . But i am not able to do it using ls or find command . Can somebody help me out ? Thanks Sanjay Gupta (2 Replies)
Discussion started by: sanajyg_mnit
2 Replies

4. Shell Programming and Scripting

Finding files which are modified few mins ago

Hi All, I have a requirement to find out the files which are modified in the last 10 minutes. I tried the find command with -amin and -mmin options, but its not working on my AIX server. Can anyone of you could help me. Thanks in advance for your help. Raju (3 Replies)
Discussion started by: rajus19
3 Replies

5. Shell Programming and Scripting

Unzip files where modified time>05:00 ?

Hello :D I am on the shell prompt in a directory, with couple of zip files in it. How can I unzip '*.zip' where modified time > 05:00 ...please help Regards SunnyK (3 Replies)
Discussion started by: SunnyK
3 Replies

6. UNIX for Dummies Questions & Answers

deleting files based on file name and modified time

Hi, I have some log files created in the following fashion Ex: file name modified date 1) s.log1 01-jan-08 2) s.log2 02-jan-08 3) s.log3 03-jan-08 4) s.log4 04-jan-08 Now I want to have the latest 2 logs and delete the others. Can you tell me the one liner /... (1 Reply)
Discussion started by: ammu
1 Replies

7. UNIX for Advanced & Expert Users

Finding the modified date time of a file

Hi, I am new bie to Unix. Might be a simple question I am asking. I want to find the last modified time of a file and find the difference between the currrent time and the last modified time. Appreciate, if someone can throw some light on what commands can be used. Cheers, James (2 Replies)
Discussion started by: JamesJoe
2 Replies

8. Emergency UNIX and Linux Support

Is there any way to set the files modified date and stamp to last modifies time?

Actually i did modification in a file on server by mistake, now its showing current time stamp, is there any way to set the files modified date and stamp to last modifies time. Please advice here.Thanks in advance.:b: (7 Replies)
Discussion started by: saluja.deepak
7 Replies

9. UNIX for Advanced & Expert Users

Need to search for keywords within files modified at a certain time

I have a huge list of files in an Unix directory (around 10000 files). I need to be able to search for a certain keyword only within files that are modified between certain date and time, say for e.g 2012-08-20 12:30 to 2012-08-20 12:40 Can someone let me know what would be the fastest way... (10 Replies)
Discussion started by: virtual123
10 Replies

10. UNIX for Dummies Questions & Answers

Finding the modified timestamp of files from the piped output of du command

Version Info +++++++++++++++ RHEL 5.4 Since ls command lists file sizes in Bytes which can be long I use du command like below. I have run the du command for the below files as shown below. But I want pipe this output to ls command just to see the modified timestamp for these files. ... (7 Replies)
Discussion started by: kraljic
7 Replies
HTML::CalendarMonth::Locale(3pm)			User Contributed Perl Documentation			  HTML::CalendarMonth::Locale(3pm)

NAME
HTML::CalendarMonth::Locale - Front end class for DateTime::Locale SYNOPSIS
use HTML::CalendarMonth::Locale; my $loc = HTML::CalendarMonth::Locale->new( id => 'en_US' ); # list of days of the week for locale my @days = $loc->days; # list of months of the year for locale my @months = $loc->months; # the name of the current locale, as supplied the id parameter to # new() my $locale_name = $loc->id; # the actual DateTime::Locale object my $loc = $loc->loc; 1; DESCRIPTION
HTML::CalendarMonth utilizes the powerful locale capabilities of DateTime::Locale for rendering its calendars. The default locale is 'en_US' but many others are available. To see this list, invoke the class method HTML::CalendarMonth::Locale->locales() which in turn invokes DateTime::Locale::ids(). This module is mostly intended for internal usage within HTML::CalendarMonth, but some of its functionality may be of use for developers: METHODS
new() Constructor. Takes the following parameters: id Locale id, e.g. 'en_US'. full_days Specifies whether full day names or their abbreviations are desired. Default 0, use abbreviated days. full_months Specifies whether full month names or their abbreviations are desired. Default 1, use full months. id() Returns the locale id used during object construction. locale() Accessor method for the DateTime::Locale class, which in turn offers several class methods of specific interest. See DateTime::Locale. locale_map() Returns a hash of all available locales, mapping their id to their full name. loc() Accessor method for the DateTime::Locale instance as specified by "id". See DateTime::Locale. locales() Lists all available locale ids. Equivalent to locale()->ids(), or DateTime::Locale->ids(). days() Returns a list of days of the week, Sunday first. These are the actual unique day strings used for rendering calendars, so depending on which attributes were provided to "new()", this list will either be abbreviations or full names. The default uses abbreviated day names. Returns a list in list context or an array ref in scalar context. narrow_days() Returns a list of short day abbreviations, beginning with Sunday. The narrow abbreviations are not guaranteed to be unique (i.e. 'S' for both Sat and Sun). days_minmatch() Provides a hash reference containing minimal case-insensitive match strings for each day of the week, e.g., 'sa' for Saturday, 'm' for Monday, etc. months() Returns a list of months of the year, beginning with January. Depending on which attributes were provided to "new()", this list will either be full names or abbreviations. The default uses full names. Returns a list in list context or an array ref in scalar context. narrow_months() Returns a list of short month abbreviations, beginning with January. The narrow abbreviations are not guaranteed to be unique. months_minmatch() Provides a hash reference containing minimal case-insensitive match strings for each month of the year, e.g., 'n' for November, 'ja' for January, 'jul' for July, 'jun' for June, etc. daynums() Provides a hash reference containing day of week indices for each fully qualified day name as returned by days(). daynum($day) Provides the day of week index for a particular day name. dayname($day) Provides the fully qualified day name for a given string or day index. monthnums() Provides a hash reference containing month of year indices for each fully qualified month name as returned by months(). monthnum($month) Provides the month of year index for a particular month name. monthname($month) Provides the month name for a given string or month index. minmatch_hash(@list) This is the method used to generate the case-insensitive minimal match hash referenced above. Given an arbitrary list, a hash reference will be returned with minimal match strings as keys and the original strings as values. lc_minmatch_hash(@list) Same as minmatch_hash, except keys are forced to lower case. first_day_of_week() Returns a number from 0 to 6 representing the first day of the week for this locale, where 0 represents Sunday. AUTHOR
Matthew P. Sisk, <sisk@mojotoad.com> COPYRIGHT
Copyright (c) 2010 Matthew P. Sisk. All rights reserved. All wrongs revenged. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. SEE ALSO
HTML::CalendarMonth(3), DateTime::Locale(3) perl v5.12.4 2011-09-28 HTML::CalendarMonth::Locale(3pm)
All times are GMT -4. The time now is 08:04 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy