bash ftp按日期获取最后修改的文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3343558/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
ftp getting last modified file by date
提问by soField
i am connecting remote server via ftp and i am sending ls -t command but it's outputting files sorted by name
我正在通过 ftp 连接远程服务器,我正在发送 ls -t 命令,但它正在输出按名称排序的文件
how can i get last modified file via ftp ?
如何通过 ftp 获取最后修改的文件?
Note: i am connecting windows ftp server from linux machine
注意:我正在从 linux 机器连接 windows ftp 服务器
回答by JoseK
ls -t
will give you the last modified file on top
ls -t
会给你最后修改的文件
You can confirm this by viewing with full timestamps
您可以通过查看完整的时间戳来确认这一点
ls -lt
回答by David W.
In mostUnix/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.
在大多数基于 Unix/Linux 的 ftp 服务器中,ls
命令链接到实际ls
命令。这就是为什么所有其他答案都说可以使用ls -t
更多的参数。
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:
但是,由于您使用的是 Windows 计算机作为服务器,因此很难说该命令究竟如何工作。我不相信 Windows 带有默认的 FTP 服务器服务。我知道许多站点在他们的 Windows 机器上使用第三方 FTP 服务。这将取决于您的 Windows 机器使用的软件,以及它是如何设置的:
Try something like this:
尝试这样的事情:
ftp> dir /O:D
or
或者
ftp> ls /O:D
These use the Windows parameters for the built in dir
command.
这些将 Windows 参数用于内置dir
命令。
回答by Mrk
try this one, it worked for me.
试试这个,它对我有用。
ls -t1 | head -1
回答by ghostdog74
ftp -n server <<EOF|awk 'END{for(i=9;i<=NF;i++)printf "%s ",$i}'
user username password
ls -ltr
EOF