Sponsored Content
Top Forums UNIX for Advanced & Expert Users File Time Comparison Question Post 38695 by davidg on Wednesday 23rd of July 2003 02:06:36 PM
Old 07-23-2003
Hi,

I knew I'dd seen this question before.
The thing is that the command "find" will only count per day (24 hours), so therefor you'dd make a refference file :

touch -amt 07231951 /tmp/ref

And use the -newer option from find :

find /tmp -newer /tmp/ref

If it results anything you know it's older, right ?

Also a perl-script could help you out a bit. You should do some work still, thought Smilie

#!/opt/perl/bin/perl

$filename = "$ARGV[0]";

@s = stat($filename);

$atime = localtime($s[8]);
$mtime = localtime($s[9]);
$ctime = localtime($s[10);

print "Time of the last access (atime) = $atime\n";
print "Time of last inode change (ctime) = $ctime\n";
print "Time of the last modification (mtime) = $mtime\n";

@yourservice
David
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Newbee Needs Help - Time comparison

I am very new to Unix so please bear with me! I am trying to write a script that will compare file creation time with the current time so I can be notified if a file is more than an hour old. Can anybody point me in the right direction on this??? Thank you in advance for any help!!! It is GREATLY... (4 Replies)
Discussion started by: danedder
4 Replies

2. Shell Programming and Scripting

Help with time comparison shell script for HP-UX

I am using Korne Shell in HP-Ux. Can someone give me and idea on how I can write a shellscript on how to do this please:- On our HP-UX server, a batch file is run every evening at about 6:30pm. The first step of this batch file will touch an empty "flag" file to indicate that the batch has... (6 Replies)
Discussion started by: gummysweets
6 Replies

3. Shell Programming and Scripting

Files manipulation with time comparison

Hi guys - I am new to Unix and learning some basics. I have to create a report of files that are in a specific directory and I have to list filenames with specific titles. This report will be created everyday early in the morning, say at 05:00 AM. (see output file format below) The 2 categories... (2 Replies)
Discussion started by: sksahu
2 Replies

4. Shell Programming and Scripting

Time comparison

hi friends, I am new to shell scripting and i am using KSH shell .I would like to automate our daily routine manual tasks .first i ll explain the situation .I will list out the contents of directory named "log" using "ls " and verify whether all the listed files time differences is... (3 Replies)
Discussion started by: rdhaprakasam
3 Replies

5. Shell Programming and Scripting

Date comparison in file to system time

I have a CSV (comma separated vaule) file whose entries resemble Area,\\ntsvsp02\vmcs\download\files\Areas.dat,1,20090303,0,Import Complete,2009-03-02 04:23:00 Product,\\ntsvsp02\vmcs\download\files\items.dat,1,20090303,0,Import Complete,2009-03-02 04:23:00... (3 Replies)
Discussion started by: zainravi
3 Replies

6. Shell Programming and Scripting

System time comparison to fixed defined time

I have a requirement of checking the current system time and performing certain actions in a shell script. example: if the current system time is greater than 1400 hrs, then perform step 1,2,3 if the current system time is greater than 1000 hrs, then perform step 1,2 if the current system time... (2 Replies)
Discussion started by: zainravi
2 Replies

7. Homework & Coursework Questions

Date comparison with 'string date having slashes and time zone' in Bash only

1. The problem statement, all variables and given/known data: I have standard web server log file. It contains different columns (like IP address, request result code, request type etc) including a date column with the format . I have developed a log analysis command line utility that displays... (1 Reply)
Discussion started by: TariqYousaf
1 Replies

8. Shell Programming and Scripting

File modification time comparison

Hi All, I have two files (given below) each exists under different paths. I want to compare the modification time stamp of file1.txt is lessthan the modification time of file2.txt. month1=`ls -l file1.txt | awk '{ print $6}'` date1=`ls -file1.txt | awk '{ print $7}'` time1=`ls... (1 Reply)
Discussion started by: Arunprasad
1 Replies

9. Shell Programming and Scripting

Date and Time comparison using shell script

Hi, I'm having two fields in the file F1|F2 20111220|102000 F1 ->YYYYMMDD F2 ->HHMMSS Now, I need to compare this with current date & time and need to return the difference value in hours. Already, I checked with datecalc from the forum. So, need hints from Shell Gurus. Thanks (10 Replies)
Discussion started by: buzzusa
10 Replies

10. Shell Programming and Scripting

File Comparison: Print Lines not present in another file

Hi, I have fileA.txt like this. B01B02 D0011718 B01B03 D0012540 B01B04 D0006145 B01B05 D0004815 B01B06 D0012069 B01B07 D0004064 B01B08 D0011988 B01B09 D0012071 B01B10 D0005596 B01B11 D0011351 B01B12 D0004814 B01C01 D0011804 I want to compare this against another file (fileB.txt)... (3 Replies)
Discussion started by: genehunter
3 Replies
Time::Seconds(3pm)					 Perl Programmers Reference Guide					Time::Seconds(3pm)

NAME
Time::Seconds - a simple API to convert seconds to other date values SYNOPSIS
use Time::Piece; use Time::Seconds; my $t = localtime; $t += ONE_DAY; my $t2 = localtime; my $s = $t - $t2; print "Difference is: ", $s->days, " "; DESCRIPTION
This module is part of the Time::Piece distribution. It allows the user to find out the number of minutes, hours, days, weeks or years in a given number of seconds. It is returned by Time::Piece when you delta two Time::Piece objects. Time::Seconds also exports the following constants: ONE_DAY ONE_WEEK ONE_HOUR ONE_MINUTE ONE_MONTH ONE_YEAR ONE_FINANCIAL_MONTH LEAP_YEAR NON_LEAP_YEAR Since perl does not (yet?) support constant objects, these constants are in seconds only, so you cannot, for example, do this: "print ONE_WEEK->minutes;" METHODS
The following methods are available: my $val = Time::Seconds->new(SECONDS) $val->seconds; $val->minutes; $val->hours; $val->days; $val->weeks; $val->months; $val->financial_months; # 30 days $val->years; $val->pretty; # gives English representation of the delta The usual arithmetic (+,-,+=,-=) is also available on the objects. The methods make the assumption that there are 24 hours in a day, 7 days in a week, 365.24225 days in a year and 12 months in a year. (from The Calendar FAQ at http://www.tondering.dk/claus/calendar.html) AUTHOR
Matt Sergeant, matt@sergeant.org Tobias Brox, tobiasb@tobiasb.funcom.com BalieXXzs SzabieXX (dLux), dlux@kapu.hu LICENSE
Please see Time::Piece for the license. Bugs Currently the methods aren't as efficient as they could be, for reasons of clarity. This is probably a bad idea. perl v5.16.2 2012-10-11 Time::Seconds(3pm)
All times are GMT -4. The time now is 08:00 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy