in reply to Re^2: Which feed method?
in thread Which feed method?

Actually, as YourMother pointed out, -M is script start time minus file modification time, in days. So, you will get different results every time your script is started.

Using stat, however, will give you the actual modification time in seconds since the epoch.1 You will always get the most recent time the file was modified no matter when your script was started.


1If you don't know what the epoch is, don't worry, it's just a fixed point in time defined in a standard.

Replies are listed 'Best First'.
Re^4: Which feed method?
by hankcoder (Scribe) on May 10, 2016 at 14:49 UTC

    Thanks RonW, -M actually serve my purpose if I only going to get modification time in days.

    The stat yes will give actual modification time in seconds. I have tested it out. However, on my script start/execution, I still need get current time() and make compare to file modification time so I can get "x time ago". Perhaps I misunderstand of stat where there are better way to achieve my goal.

      Both methods will give you a number related to when the file was modified.

      With -M, any time your script was restarted, any saved modification time would be relative to an old reference: the previous run of your script. Unless you also saved the last start time of your script, you would have to make an assumption about the "newness" of the file.

      With stat, the reference is always the epoch, so your saved modification time will always be valid, no matter when your script last ran nor how many times it was restarted.

Re^4: Which feed method?
by hankcoder (Scribe) on May 10, 2016 at 17:17 UTC

    Sorry, little off topic. This should be about feed. -M were useful to me as well.