Results 1 to 4 of 4
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 ...
- 10-31-2007 #1Just Joined!
- Join Date
- Oct 2007
- Posts
- 4
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:
Filename2007103105
or
Filename2007103107
Any ideas?
Thanks in advance for any help.
- 11-01-2007 #2Linux User
- Join Date
- Aug 2006
- Posts
- 458
just one way of doing:
if you have stat command, with combination of GNU date command
save them to variables, calculate how many seconds is 15 minutesCode:stat -c "%y" file date +%s -d "15 minute ago" # or just date +%s
and do some maths.
- 11-01-2007 #3Just Joined!
- Join Date
- Oct 2007
- Posts
- 15
You can use find program. It has a lot of option to deal with timetamp, file size, permissions, etc.
Valery.
- 11-06-2007 #4Just Joined!
- Join Date
- Oct 2007
- Posts
- 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.


Reply With Quote