Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

latest file in the directory

Status
Not open for further replies.

dvknn

IS-IT--Management
Mar 11, 2003
94
US
I need to find the latest file in the directory. The files in the script are in:

12n%m%d.%y. I need to find the latest file.

I can do it if I execute
ls 12n*.03

I want to replace the '03' with %y'. How can I do that?

Thanks.
 
lYEAR=`date '+%yy'`
lFILENAME="12n*."$lYEAR
ls $lFILENAME

However, if you are looking for the last file touched:
ls -ctrl directoryname | tail -1
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top