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

Thank you man. I'm not very good in technical details. However I have learn something new from your suggestions. I didn't know I can check file stat of modified age.

Could you correct me if I'm wrong, is it using -M $filename > n days ? -M (Modification age)

Replies are listed 'Best First'.
Re^3: Which feed method?
by Your Mother (Archbishop) on May 08, 2016 at 06:38 UTC

    Yeppers. -X: -M Script start time minus file modification time, in days. See also stat.

Re^3: Which feed method?
by RonW (Parson) on May 10, 2016 at 01:07 UTC

    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.

      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.

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