Determining age of a file in shell script

后端 未结 6 1091
暖寄归人
暖寄归人 2021-01-04 18:28

G\'day,

I need to see if a specific file is more than 58 minutes old from a sh shell script. I\'m talking straight vanilla Solaris shell with some POSIX extensions i

6条回答
  •  隐瞒了意图╮
    2021-01-04 18:45

    Since you're looking to test the time of a specific file you can start by using test and comparing it to your specially created file:

    test /path/to/file -nt /var/tmp/toto
    

    or:

    touch -t YYYYMMDDHHmm.SS /var/tmp/toto
    if [/path/to/file -nt /var/tmp/toto]
       ...
    

提交回复
热议问题