Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com X-VirusChecked: Checked X-Env-Sender: devnull4spam AT yahoo DOT co DOT uk X-Msg-Ref: server-6.tower-70.messagelabs.com!1119950547!59309567!1 X-StarScan-Version: 5.4.15; banners=.,-,- Message-ID: <42C1178E.6080705@yahoo.co.uk> Date: Tue, 28 Jun 2005 10:25:34 +0100 From: Allan WIlkins User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7) Gecko/20040616 MIME-Version: 1.0 To: cygwin AT cygwin DOT com Subject: Re: find -newer problem References: <42BFE607 DOT 2070804 AT yahoo DOT co DOT uk> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Note-from-DJ: This may be spam Iv done a bit more investigating. as I thought It might be something to do with the seconds (ls -l not displaying the seconds). The program t.c containing: #include #include #include main(int argc,char *argv[]) { struct stat finfo; stat(argv[1],&finfo); printf("Access : %s\n",ctime(&finfo.st_atime)); printf("Modification: %s\n",ctime(&finfo.st_mtime)); printf("Change : %s\n",ctime(&finfo.st_ctime)); } produces: $ ./t XXX Access : Tue Jun 28 00:00:00 2005 Modification: Mon Jun 27 12:21:30 2005 Change : Mon Jun 27 12:21:30 2005 $ ./t YYY Access : Tue Jun 28 00:00:00 2005 Modification: Mon Jun 27 12:21:30 2005 Change : Mon Jun 27 12:21:30 2005 Exactly the same times so I wrote : #include #include #include main(int argc,char *argv[]) { struct stat finfo1, finfo2; stat(argv[1],&finfo1); stat(argv[2],&finfo2); printf("%s: %s",argv[1],ctime(&finfo1.st_mtime)); printf("%s: %s",argv[2],ctime(&finfo2.st_mtime)); if (finfo1.st_mtime > finfo2.st_mtime){ printf("File 1 newer than file 2\n",ctime(&finfo2.st_mtime)); } } that produces: $ ./fcmp XXX YYY XXX: Mon Jun 27 12:21:30 2005 YYY: Mon Jun 27 12:21:30 2005 $ >a $ >b $ ./fcmp b a b: Tue Jun 28 10:19:44 2005 a: Tue Jun 28 10:19:42 2005 File 1 newer than file 2 So I've now written newer.c to solve my problem #include #include #include main(int argc,char *argv[]) { struct stat finfo1, finfo2; stat(argv[1],&finfo1); stat(argv[2],&finfo2); if (finfo1.st_mtime > finfo2.st_mtime){ printf("%s\n",argv[1]); } } But I still don't really understand what find is doing. Sorry about the cygcheck -s -v -r :-( Al Igor Pechtchanski wrote: >On Mon, 27 Jun 2005, Allan WIlkins wrote: > > > >>I must apologise if this is an already known problem but I have been >>unable to locate any reference to it in the mail archives. >> >>Executing a find using the -newer parameter returns files that appear to >>be of the same age. e.g. >> >>$ find XXX -newer YYY >>XXX >>$ ls -l XXX YYY >>-r--r--r-- 1 allanw Domain Users 10291 Jun 27 10:38 XXX >>-r--r--r-- 1 allanw Domain Users 5865 Jun 27 10:38 YYY >>$ ls -lu XXX YYY >>-r--r--r-- 1 allanw Domain Users 10291 Jun 27 00:00 XXX >>-r--r--r-- 1 allanw Domain Users 5865 Jun 27 00:00 YYY >>$ ls -lc XXX YYY >>-r--r--r-- 1 allanw Domain Users 10291 Jun 27 12:21 XXX >>-r--r--r-- 1 allanw Domain Users 5865 Jun 27 12:21 YYY >> >>However: >>$ touch AAA BBB >>$ find AAA -newer BBB >>$ ls -l AAA BBB >>-rw-r--r-- 1 allanw Domain Users 0 Jun 27 12:11 AAA >>-rw-r--r-- 1 allanw Domain Users 0 Jun 27 12:11 BBB >>$ ls -lc AAA BBB >>-rw-r--r-- 1 allanw Domain Users 0 Jun 27 12:11 AAA >>-rw-r--r-- 1 allanw Domain Users 0 Jun 27 12:11 BBB >>$ ls -lu AAA BBB >>-rw-r--r-- 1 allanw Domain Users 0 Jun 27 00:00 AAA >>-rw-r--r-- 1 allanw Domain Users 0 Jun 27 00:00 BBB >>So if the files are created using touch the find does not return anything. >> >>I understand that ls -l displays the last modification time. Is the find >>using the same date? >> >> > >find *is* using the same date, but you may be running into filesystem >granularity issues. FAT, for example, stores dates with the granularity >of 2 seconds. You may also want to try "test AAA -nt BBB" and "test BBB >-nt AAA", to see whether you get results that are consistent with "find". > > > >>Thanks in advance >>Al >> >>The output of a cygcheck -s -v -r > cygcheck.out follows >>==================================================== >>[snip cygcheck output] >>[snip *another* cygcheck output] >> >> > >In the future, please *attach* the output of "cygcheck -svr" instead of >including it in-line. It cuts down on false positive matches in archive >searches. > >HTH, > Igor > > ______________________________________________________________________ This email has been scanned by the MessageLabs Email Security System. For more information please visit http://www.messagelabs.com/email ______________________________________________________________________ -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/