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
ls -t
will give you the last modified file on top
You can confirm this by viewing with full timestamps
ls -lt
ftp -n server <<EOF|awk 'END{for(i=9;i<=NF;i++)printf "%s ",$i}'
user username password
ls -ltr
EOF
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With