Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ftp getting last modified file by date

Tags:

bash

ftp

i am connecting remote server via ftp and i am sending ls -t command but it's outputting files sorted by name

how can i get last modified file via ftp ?

Note: i am connecting windows ftp server from linux machine

like image 595
soField Avatar asked Jul 27 '10 12:07

soField


3 Answers

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

You can confirm this by viewing with full timestamps

ls -lt
like image 161
JoseK Avatar answered Nov 15 '22 07:11

JoseK


ftp -n server <<EOF|awk 'END{for(i=9;i<=NF;i++)printf "%s ",$i}'
user username password
ls -ltr
EOF
like image 42
ghostdog74 Avatar answered Nov 15 '22 09:11

ghostdog74


In most Unix/Linux based ftp servers, the ls command is linked to the actual ls command. This is why all the other answers are saying to use ls -t with maybe a few more parameters thrown in.

However, since you're using a Windows machine as your server, it's much harder to say how exactly the command will work. I don't believe Windows comes with a default FTP server service. I know many sites use third party FTP services on their Windows machines. It's going to depend on the software your Windows machine is using, and how it's been setup:

Try something like this:

ftp> dir /O:D

or

ftp> ls /O:D

These use the Windows parameters for the built in dir command.

like image 30
David W. Avatar answered Nov 15 '22 07:11

David W.