Ftp retrieve last modified file by date

I connect the remote server via ftp and I send the ls -t command, but it displays files sorted by name

how can i get the last modified file via ftp?

Note: I connect windows ftp server from a Linux machine

+4
source share
4 answers

ls -t will give you the last modified file on top

You can confirm this by looking at all timestamps.

 ls -lt 
+3
source
 ftp -n server <<EOF|awk 'END{for(i=9;i<=NF;i++)printf "%s ",$i}' user username password ls -ltr EOF 
0
source

On most Unix / Linux-based ftp servers, the ls is associated with the actual ls . That's why all the other answers say use ls -t , maybe a few more options.

However, since you are using a Windows computer as your server, it is much more difficult to say exactly how the team will work. I do not believe that Windows comes with an FTP server by default. I know that many sites use third-party FTP services on their Windows machines. It depends on the software used by your Windows machine and how it was configured:

Try something like this:

 ftp> dir /O:D 

or

 ftp> ls /O:D 

They use Windows options for the built-in dir command.

0
source

try this one, it worked for me.

 ls -t1 | head -1 
0
source

All Articles