tags:

views:

52

answers:

2

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

A: 

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

You can confirm this by viewing with full timestamps

ls -lt
JoseK
doesn't work in ftp
soField
@soField, works perfectly. What ftp client are you using? Regular `ftp`?
Anders
we are using windows based ftp server , does it matter ? because when we run ls or ls -t output is same always returns files sorted by name , please see note section i updated question above thanks
soField
@soField: I've tried from command window - FTP to my server and it works. Can you try the same?
JoseK
yeah i tried from windows command line too, same output again , lt ineffective
soField
This depends on server behavior, not portable, not reliable.
bstpierre
@bstpierre so *what is* the right answer?
JoseK
@JoseK There is no right answer. It depends on the server. If the OP only needs it to work for his server, he can try `ls /od` or `ls -od` (these are DOS `dir` flags) or check the server documentation.
bstpierre
A: 
ftp -n server <<EOF|awk 'END{for(i=9;i<=NF;i++)printf "%s ",$i}'
user username password
ls -ltr
EOF
ghostdog74