How to find the create time of a file if current date is in next month

Hi All,

I want to find the time diffrence between currnt time and "abc.txt" file create time.
I have solve that but if the abc.txt file created last month then is there any process to find the difftent?

Exp:
Create time of abc.txt is "Apr 14 06:48"

and currect date is "May 17 23:47".

I need a logic that say the time difference is greter then 20 hrs.

Please help.

try this remove the unnecessary part :smiley:

function time_diff
{
awk -v start_time=$1 -v end_time=$2 'BEGIN{
if ( start_time !~ /^[0-9]/ || end_time !~ /^[0-9]/ )
usage(start_time,end_time)
split(start_time,T2,":")
split(end_time,T1,":")
start_seconds=T1[1]*60*60+T1[2]*60+T1[3]
end_seconds=T2[1]*60*60+T2[2]*60+T2[3]
if ( start_seconds > 86401 || end_seconds > 86401)
usage("out_off_range","")
elapsed_seconds=start_seconds-end_seconds
if( elapsed_seconds < 0 )
{elapsed_seconds=elapsed_seconds*-1
calculate(end_time,start_time,elapsed_seconds)}
else
calculate(start_time,end_time,elapsed_seconds)}
function calculate(start_time,end_time,elapsed_seconds){
HH=elapsed_seconds / 3600
MM=(elapsed_seconds % 3600) / 60
SS=elapsed_seconds % 60
printf  "TIME DIFFERENCE BETWEEN "start_time"(START TIME)-"end_time"(END TIME)--> +%02d:%02d:%02d\n",HH,MM,SS }
function usage(start_time,end_time){
if( start_time=="out_off_range" )
printf "TIME OUT OFF RANGE\n"
else
printf "INVALID TIME FORMAT "start_time" "end_time"\n"
printf "USAGE : time_diff.sh <HH:MM[:SS]> <HH:MM[:SS]>\n"
exit}'
}
time_file=`ls -l abc.txt|awk '{print $8}'`
time_current=`date +%T`
time_diff $time_file $time_current