The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
to get the timestamp of files from the files and folders in Unix kishan HP-UX 2 04-09-2008 05:20 AM
how to compare the timestamp of 2 files mail2sant Shell Programming and Scripting 2 04-07-2008 01:43 AM
comparing shadow files with real files terrym UNIX for Advanced & Expert Users 4 02-08-2007 10:38 PM
ftp files -- but keep the original timestamp Perderabo Answers to Frequently Asked Questions 0 07-23-2006 08:43 AM
How do i check if 2 files have same timestamp? pt14 AIX 1 11-18-2005 09:54 AM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-06-2004
Registered User
 

Join Date: Oct 2001
Location: Bangalore
Posts: 93
comparing timestamp of two files

Hi!

I need to copy a whole bunch of file from a build directory to my working directory. Many of these files already exist in my working directory. I need to copy only those files that have been modified since I last copied..

How do I compare the timestamp of two files, so that I would copy only the file if it is newer.

Thanks,
JP
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 04-06-2004
Ygor's Avatar
Moderator
 

Join Date: Oct 2003
Location: -31.96,115.84
Posts: 1,221
if [ file1 -nt file2 ]
then
echo file1 is newer than file2
fi
Reply With Quote
  #3 (permalink)  
Old 04-06-2004
s93366's Avatar
Registered User
 

Join Date: Apr 2002
Location: sweden
Posts: 152
You could also use the find command.
# find /blabla/*.txt -newer thisfile.txt
will only display files newer then thisfile.txt

/Peter
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 03:18 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0