Find the answer to your Linux question:
Results 1 to 4 of 4
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    How to prgrammatically compare a file timestamp against currrent time

    I need to use kshell to compare a file's date/timestamp to the current day and time and if they are within fifteen minutes of each other(give or take) it will then perform another action.

    The filenames will always be different, but will start out with the same 10 characters, but be followed with the date and hour. For example it may be called:


    Any ideas?

    Thanks in advance for any help.

  2. #2
    just one way of doing:
    if you have stat command, with combination of GNU date command
    stat -c "%y" file
    date +%s -d "15 minute ago"  # or just date +%s
    save them to variables, calculate how many seconds is 15 minutes
    and do some maths.

  3. #3
    You can use find program. It has a lot of option to deal with timetamp, file size, permissions, etc.


  4. $spacer_open
  5. #4
    Thank you Valery and Ghost dog for your help.

    I ended up using ghost dog's recommendation and it worked great, but thanks again Valery for your help as well.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts