delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2005/06/28/05:22:59

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
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 <devnull4spam AT yahoo DOT co DOT uk>
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> <Pine DOT GSO DOT 4 DOT 61 DOT 0506270916560 DOT 10029 AT slinky DOT cs DOT nyu DOT edu>
In-Reply-To: <Pine.GSO.4.61.0506270916560.10029@slinky.cs.nyu.edu>
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 <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>

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 <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>

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 <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>

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/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019