Want to download a latest file with current date from FTP location

Dear Friends,

I need help to write a shell / perl script to download the files from FTP location, having different file names (date inside the file name).

Example:

Mar 5 09:24 cfx_03052013_return_file.txt
Mar 6 02:13 cfx_03062013_return_file.txt
Mar 7 06:40 cfx_03072013_return_file.txt
Mar 8 08:07 cfx_03082013_return_file.txt
Mar 9 06:18 cfx_03092013_return_file.txt
Mar 10 05:23 cfx_03102013_return_file.txt
Mar 15 05:40 cfx_03152013_return_file.txt
Mar 13 05:40 cfx_03132013_return_file.txt

Since Linux commands doesn't work within the FTP, I need a script to download only the latest file (not all files).

Please help !!

Thanks in advance.

Regards
Praveen

ftp has a ls, so try some ls options. Else, do ls and extract and sort and extract from your own log to generate the get. Or two ftp sessions, first for ls to pipe to ....

Or use a more "scrip-friendly" tool like curl, lftp, ncftp, etc. All of them support wildcards, time comparisson, listing, etc.

I see ftp 'ls -t' and 'ls -tr' do time sorts, so extracting the first file should be easy if your target host ftpd is like mine.