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
to compare latest logfile with the current running time of the script mail2sant Shell Programming and Scripting 0 04-06-2008 08:45 PM
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
compare update time of files dorilevy UNIX for Dummies Questions & Answers 8 05-27-2003 09:48 AM
Compare two files b5fnpct UNIX for Dummies Questions & Answers 2 08-16-2001 03:28 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 05-19-2002
AkumaTay AkumaTay is offline
Registered User
  
 

Join Date: Jul 2001
Location: Malaysia
Posts: 21
compare files acess time

I need to compare x file with y file.
If x file is newer than y file do xxxx;
(I used touch -t yymmddxxx to chnage the time for y file)

How can i do that?

I tried use
if [ $x -ot $y ]
then
echo "Xxx";;
fi

But cant....any other good ways to do it?
  #2 (permalink)  
Old 05-19-2002
Bab00shka Bab00shka is offline
Registered User
  
 

Join Date: Apr 2002
Location: Chesterfield, UK
Posts: 123
Try this:

if [ `find xfile -newer yfile` ]
then
echo "xxx"
fi

In the above we are testing for a string to be returned.

If xfile is newer than yfile then the find statement will return the string "xfile", hence the test will be true and perform the if statement.

If xfile is not newer than yfile then the find statement will not return anything, so the test will be false and the if statement will not be performed.

Let me know how you get on.

Cheers
Helen
  #3 (permalink)  
Old 05-19-2002
AkumaTay AkumaTay is offline
Registered User
  
 

Join Date: Jul 2001
Location: Malaysia
Posts: 21
Quote:
Originally posted by Bab00shka
Try this:

if [ `find xfile -newer yfile` ]
then
echo "xxx"
fi

In the above we are testing for a string to be returned.

If xfile is newer than yfile then the find statement will return the string "xfile", hence the test will be true and perform the if statement.

If xfile is not newer than yfile then the find statement will not return anything, so the test will be false and the if statement will not be performed.

Let me know how you get on.

Cheers
Helen
Thx !..I had got it done!.. from: AkumaTay
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 04:33 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
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