Finding the Latest file in a Dir

Hi Everyone,

I am writing a shell script and I am struck here:

I need to find the latest file in a directory depending upon the date.

For example:

The files in the directory are:

Filename_bo_20110619
Filename_bo_20110620
Filename_bo_20110621
Filename_bo_20110622

So here, I want to pick up the lastest file ( Filename_bo_20110622) in the directory.

but Todays Date: 20110624. and the file doen't exists in the dir for todays date so I need to pick up the latest file that exists in the dir.

Could someone please help me out in this. I want to integrate the logic in the shell script.

Any ideas would be really appreciated.

ls -t | grep "^Filename_bo_20" | head -n 1

The filenames come out in date order in a normal "ls".

ls -1d Filename_bo_* 2>/dev/null | tail -1

The "2>/dev/null" redirects the error channel if there are no files.