in reply to ls dates vs stat() ages

Note "ls -Flc" appears to give ctime, not "modification time" mtime. It's actual usage varies greatly depending on your OS and is generally when the file's *status* changes, not the file data itself. See perldoc -f stat and especially "perldoc perlport" and then look for 'ctime' in the stat entry. Generally, atime >= mtime since it is the last access time or the modification time, whichever is more recent.

FWIW, depending on what you are trying to do, it may be impossible to guarantee that mtime/atime/ctime will be usefull. For example if users can touch files with arbitrary dates (e.g. using touch or "tar -xf" to dearchive a tree), then you have no real way of determining age based on atime or mtime (and perhaps ctime).

Replies are listed 'Best First'.
Re^2: ls dates vs stat() ages
by Dismas (Acolyte) on Sep 28, 2004 at 17:23 UTC
    Hey, Bluto, Thanks for the answer. I've had several responses explaining how I've misinterpreted, mishandled, and/or misused the data returned by stat(). Maybe I'll revisit it.

    OTOH, things on the "ls" front keep getting more and more confusing. I've been using ls with the -u flag for "access time" and the -c flag for "modification time."

    Now it seems that what I *might* want is the default time returned by ls without any date-related flag because the -c flag hooks things like chmod, chown, etc., while the default hooks only changes to the file's data. Hmmm.....

    Thanks again!