Last "real" modification date of file

B

Bart Van der Donck

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,
 
J

Jürgen Exner

Bart Van der Donck said:
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
 
T

Tony Curtis

Bart said:
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
 
B

Bart Van der Donck

Glenn said:
At said:
 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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top