The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Compare file time pdr302 Shell Programming and Scripting 1 11-01-2007 07:14 PM
Compare Date And Time Jamil Qadir UNIX for Dummies Questions & Answers 5 01-10-2007 11:22 AM
How to compare data in two flat files and update them? rajus19 Shell Programming and Scripting 3 11-08-2005 11:13 AM
To simultaneously update password change in two server at a time s_chandrakar Shell Programming and Scripting 0 11-07-2005 10:25 AM
compare files acess time AkumaTay UNIX for Dummies Questions & Answers 2 05-19-2002 03:02 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 05-27-2003
dorilevy dorilevy is offline
Registered User
  
 

Join Date: Aug 2002
Posts: 18
compare update time of files

Hi,

does anyone know of a way to compare files update time (not only days - also hours and minutes) (command? scripts? perl scripts?)

Dori
  #2 (permalink)  
Old 05-27-2003
yeheyaansari yeheyaansari is offline
Registered User
  
 

Join Date: Feb 2002
Location: India
Posts: 36
From whcih time you want to compare the update time?
  #3 (permalink)  
Old 05-27-2003
dorilevy dorilevy is offline
Registered User
  
 

Join Date: Aug 2002
Posts: 18
i want to compare it to the current time.
i want to get the differnce in minutes.
Example -
if a file was last updated 2 hours ago i want to get back 120.
  #4 (permalink)  
Old 05-27-2003
yeheyaansari yeheyaansari is offline
Registered User
  
 

Join Date: Feb 2002
Location: India
Posts: 36
you can use

ls -l yeh.log|sed "s/ */ /g"|cut -d" " -f6-8

to get the Update time of file

Regards,
Yeheya
  #5 (permalink)  
Old 05-27-2003
dorilevy dorilevy is offline
Registered User
  
 

Join Date: Aug 2002
Posts: 18
ok,
but is there a way to compare it??
  #6 (permalink)  
Old 05-27-2003
cbkihong cbkihong is offline Forum Advisor  
Advisor
  
 

Join Date: Sep 2002
Location: Hong Kong, China
Posts: 1,624
A dirty perl script, not knowing if this is what you want:

#!/usr/bin/perl -w

$f1 = $ARGV[0];
$f2 = $ARGV[1];

print abs((stat($f1))[9] - (stat($f2))[9])/60, "\n";


Pass the two filenames as params
  #7 (permalink)  
Old 05-27-2003
dorilevy dorilevy is offline
Registered User
  
 

Join Date: Aug 2002
Posts: 18
well,
i get strange results from that perl script.
when i run it on 2 files created with 1 hour different i get the result - 6681
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 05:04 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0