Last "real" modification date of file

Discussion in 'Perl Misc' started by Bart Van der Donck, Jun 18, 2008.

  1. Hello,

    I am on FreeBSD.

    my @stat = stat "file.txt";
    print "Last modified: ";
    print time()-$stat[9]." seconds ago";

    Is there a way to find out when file.txt was last changed ?
    I'm facing a situation when a file could legally be (re-)written with
    the same content. Don't ask me how I got there :)

    Thanks for any hints,

    --
    Bart
    Bart Van der Donck, Jun 18, 2008
    #1
    1. Advertising

  2. Bart Van der Donck <> wrote:
    >I am on FreeBSD.
    >
    >Is there a way to find out when file.txt was last changed ?
    >I'm facing a situation when a file could legally be (re-)written with
    >the same content. Don't ask me how I got there :)


    That depends upon if the file system (not the OS!) supports such a
    value.
    And for legal matters also if there are any means to set that value
    manually.

    jue
    Jürgen Exner, Jun 18, 2008
    #2
    1. Advertising

  3. Bart Van der Donck

    Tony Curtis Guest

    Bart Van der Donck wrote:
    > Hello,
    >
    > I am on FreeBSD.
    >
    > my @stat = stat "file.txt";
    > print "Last modified: ";
    > print time()-$stat[9]." seconds ago";
    >
    > Is there a way to find out when file.txt was last changed ?
    > I'm facing a situation when a file could legally be (re-)written with
    > the same content. Don't ask me how I got there :)


    Ah, you actually want to see if the *contents* of the file have changed.
    Completely different thing (the file is a container for its content;
    stat() just reports on the container). You'll need some kind of
    meta-information, e.g. md5 hash, to match against.

    hth
    t
    Tony Curtis, Jun 18, 2008
    #3
  4. Glenn Jackman wrote:

    > At 2008-06-18 10:03AM, "Bart Van der Donck" wrote:
    >
    >>  Hello,

    >
    >>  I am on FreeBSD.

    >
    >>    my @stat = stat "file.txt";
    >>    print "Last modified: ";
    >>    print time()-$stat[9]." seconds ago";

    >
    >>  Is there a way to find out when file.txt was last changed ?
    >>  I'm facing a situation when a file could legally be (re-)written with
    >>  the same content. Don't ask me how I got there :)

    >
    > You'd need to have a CRC or cksum value for the "old" and "new" file to
    > check for changed content if the timestamp has changed.


    Yes, it seems like there is no other choice than influencing the write
    process itself. Backup file, write new content, compare two versions,
    store some isModified-flag, delete backup-file.

    Thanks to all for your insights.

    --
    Bart
    Bart Van der Donck, Jun 18, 2008
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Peter Grison

    Date, date date date....

    Peter Grison, May 28, 2004, in forum: Java
    Replies:
    10
    Views:
    3,244
    Michael Borgwardt
    May 30, 2004
  2. Andy Fish
    Replies:
    0
    Views:
    615
    Andy Fish
    Jul 20, 2004
  3. Manuel Bastioni

    Get the date of last modification of a file

    Manuel Bastioni, Sep 8, 2003, in forum: Python
    Replies:
    6
    Views:
    2,044
    Manuel Bastioni
    Sep 9, 2003
  4. James E Keenan
    Replies:
    1
    Views:
    122
    Steve Grazzini
    Oct 14, 2003
  5. Vance M. Allen

    File Modification Date

    Vance M. Allen, Sep 14, 2005, in forum: Perl Misc
    Replies:
    6
    Views:
    143
    Josef Moellers
    Sep 15, 2005
Loading...

Share This Page