How to display from shell script the "last modified date" of the current script? - Unix

This is a discussion on How to display from shell script the "last modified date" of the current script? - Unix ; Assume I want to display the "last modified (date+) time of the script which is currently running. How can I access this date/time information from within the same script and display it? Karl...

+ Reply to Thread
Results 1 to 2 of 2

Thread: How to display from shell script the "last modified date" of the current script?

  1. How to display from shell script the "last modified date" of the current script?

    Assume I want to display the "last modified (date+) time of the script which is
    currently running. How can I access this date/time information
    from within the same script and display it?

    Karl

  2. Re: How to display from shell script the "last modified date" of the current script?

    Karl Medrell wrote:
    > Assume I want to display the "last modified (date+) time of the script
    > which is currently running. How can I access this date/time information
    > from within the same script and display it?


    In the general case you can't reliably do that; someone might have
    deleted and/or replaced the script shortly after you started running
    it. Or it might not be a file-based script at all, in which case there
    is no file to check. Or it might reside on a filesystem that doesn't
    provide last-modified information.

    If you're talking about a specific script, then presumably you know what
    it's called and where it is, so you can just use "ls -l".

    (There are things you can do with $0 and PATH, but they're not guaranteed
    to work in all cases. See above.)

    Chris

+ Reply to Thread