File Timestamp and date comparsion

Hi,

I have many files in the source directory but I need to process with the latest timestamp file.
I am using linux operating system. i want extract the file created timestamp( Ext_File_create_date=)
With this format YYYYMMDD-
i have searched the relevent command in the unix forms but did not find relevent information.

Example:
Jun 23 10:10 new_file22062012101010.txt
Jun 24 11:15 new_file23062012111010.txt
Jun 25 09:10 new_file24062012111590.txt #latest file

################################################--
# Get the today date with YYYYMMDD format.
################################################--
Today_date=`date +Y%m%d`

################################################--
# Extract file created date with format YYYYMMDD
################################################--
Ext_File_create_date=                 #get the file created timestamp YYYYMMDD
################################################--
# Date comparision
################################################--


if [ "$Today_date" = "$Ext_File_create_date  ]
then
echo "today file arrived"
elce 
echo 'today file not arrrived"
fi 

Thanks
Suri

There are two different dates in this record. Which of the two dates are you interested in?

What Operating System and version are you running and what Shell is this?
Also, do you have the GNU date command or Perl ?

Hi,

Operating system -linux
Shell -bash

Example: This is the latest file. I need to get the file created date.
here file created date-Jun 25 ,Final output: 20120625

Jun 25 09:10 new_file24062012111590.txt #latest file

Try this:

Ext_File_create_date=`echo *.txt | awk '{gsub(/\.[^.]*$/,"",$0); L=length;
    D=substr($0,L-9,4) substr($0,L-11,2) substr($0,L-13,2);
    if(0+D>M)M=D} END {print M}'`

treat today date as 25-06-2012

here file created date-Jun 25 ,Final output: 20120625

Jun 25 09:10 new_file24062012111590.txt #latest file

i should get the output as 20120625 but using the below command i am getting the proper output
using the below command output-> 10101210

$ echo "Jun 25 09:10 new_file24062012111590.txt" | awk '{gsub(/\.[^.]*$/,"",$0); L=length;
     D=substr($0,L-9,4) substr($0,L-11,2) substr($0,L-13,2);
     if(0+D>M)M=D} END {print M}'
20120624