![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to find the create time of a file if current date is in next month | priyankak | Shell Programming and Scripting | 1 | 05-18-2009 04:19 AM |
| Prefix the current date and time to the output of ps | Bloke | Shell Programming and Scripting | 2 | 04-08-2009 08:25 AM |
| Get date and time for past 1 hour from current date | spch2o | Shell Programming and Scripting | 5 | 08-29-2008 04:32 AM |
| param as current date+time | itik | Shell Programming and Scripting | 1 | 06-13-2008 04:25 PM |
| Processing a log file based on date/time input and the date/time on the log file | primp | Shell Programming and Scripting | 4 | 03-16-2008 11:23 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
compare file modification date/time to current date/time
How do I compare the file modification date/time to the current system date/time? I need this to check to see if a new file is being ftp'ed every hour/every 6 hours, etc.
Thanks in advance. |
|
||||
|
Code:
#!/bin/ksh
# filetimes.sh
# usage filtimes.sh [filename]
filetime()
{
perl -e '
$mtime = (stat $ARGV[0])[9];
print $mtime
' $1
}
now=$(date +%s)
limit=$(( $now - 21600 )) # 6 hours ago
ftime=$(filetime $1 )
if [[ $ftime -lt $limit ]] ; then
echo "file too old"
fi
|
![]() |
| Bookmarks |
| Tags |
| modification date, unix |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|