The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 06-22-2006
anujairaj anujairaj is offline
Registered User
  
 

Join Date: Apr 2006
Posts: 13
getting the most recent file

Hi,
I have files coming in every day with that days timestamp like:
nameyyyymmddhhmmss.ext.
I need the most recent one and so i am using

cat `ls -t name*|head -1 ` > temp

i am sorting the files in the decending order and am copying the most recent one into a temp file.
It works at times but sometimes it does not.
Is there a better way to do it?
I dont want to compare it to todays absolute date ;I just want the most recent file.
any suggestions will be appreciated.
thanks