comparing modification times of files

N

Nomen Nescio

Is this the right way to compare file timestamps?

if (-M $file >= -M $otherFile) {
# $file is not newer than $otherFile
}

And I sometimes get *modified* and *changed* mixed up...contents get
modified, permissions get changed, right?

thanks
 
B

Brian McCauley

Nomen said:
Is this the right way to compare file timestamps?

if (-M $file >= -M $otherFile) {
# $file is not newer than $otherFile
}

And I sometimes get *modified* and *changed* mixed up...contents get
modified, permissions get changed, right?

Yes, that's not the whole story but its a fair mnemonic. At least on
POSIX-like OSs.

On other OSs the meaning of changed changes but iut is generally safe
to assume that the "modified" time is the primary timestamp that you'd
have on a filesystem that only had one.
 

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
474,201
Messages
2,571,049
Members
47,652
Latest member
Campbellamy

Latest Threads

Top