FTP "ls -lt" 命令:它如何列出 Linux FTP 和 Windows FTP 服务器的文件详细信息?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11553953/
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 "ls -lt" command: How does it list the file details for Linux FTP and Windows FTP server?
提问by Learner
I am writing FTP client that should work for at least Windows and Linux FTPs. BUt before I proceed, I want answer to these questions.
我正在编写至少适用于 Windows 和 Linux FTP 的 FTP 客户端。但在我继续之前,我想回答这些问题。
- In which order files are listed when FTP
ls -lt
command is used for the FTP server on the Linux? - Is there any specific format/logic in which all Linux FTP serversprovide the list of files? e.g. DateTime stamp is going to be there always and files are listed in the descending order of the "date modfied" or something like this.
- In which order files are listed when FTP
ls -lt
command is used for the FTP server on the Windows? - Is there any specific format/logic in which all Windows FTP serversprovide the list of files?
- Can you direct me to some documentation which helps to understand this? Is there any standard defined for this?
- Linux下
ls -lt
FTP服务器使用FTP命令时文件是按什么顺序排列的? - 所有 Linux FTP 服务器都提供文件列表,是否有任何特定格式/逻辑?例如,日期时间戳记将始终存在,文件按“修改日期”或类似内容的降序排列。
- Windows
ls -lt
上的 FTP 服务器使用FTP命令时文件是按什么顺序列出的? - 是否有任何特定格式/逻辑可以让所有 Windows FTP 服务器提供文件列表?
- 你能指导我查看一些有助于理解这一点的文档吗?有没有为此定义的标准?
Note: I tried command on Windows and Linux FTP servers but I could not figure out any specific logic/format.
注意:我在 Windows 和 Linux FTP 服务器上尝试过命令,但我无法弄清楚任何特定的逻辑/格式。
采纳答案by Jon Lin
ls
is a client command. When your client gets ls -lt
from the user, you issue a LIST
command to the server and it's up to your client to parse the data returned and sort it by time. The data returned by the ftp server when you use the LIST
command is similar to the output of ls
, but it can vary from server to server. See: http://cr.yp.to/ftp/list.html
ls
是客户端命令。当您的客户端ls -lt
从用户那里获取时,您LIST
向服务器发出一个命令,由您的客户端解析返回的数据并按时间对其进行排序。使用该LIST
命令时 ftp 服务器返回的数据与 的输出类似ls
,但它可能因服务器而异。见:http: //cr.yp.to/ftp/list.html
回答by teambob
The format of the FTP ls / dir commands is server implementation dependent. It is unlikely you could rely on the order of an ls -lt command within ftp. Some server implementations may give you name order, others may give you time order.
FTP ls / dir 命令的格式取决于服务器实现。您不太可能依赖 ls -lt 命令在 ftp 中的顺序。一些服务器实现可能会给你命名顺序,其他的可能会给你时间顺序。
回答by Castaglia
Newer FTP servers should hopefully implement RFC 3659, particularly the MLSD and MLSTcommands. The format of the response for these commands -- used for listing files and directories, in a machine-parseable format -- is strictly defined by the RFC, and thus should will be the same across underlying platforms/OSes.
较新的 FTP 服务器应该有希望实现 RFC 3659,特别是MLSD 和 MLST命令。这些命令的响应格式——用于以机器可解析的格式列出文件和目录——由 RFC 严格定义,因此在底层平台/操作系统之间应该是相同的。
Unfortunately, the MLSD/MLST commands, while addressing the format of the responses, make no guarantee about the ordering of the files within a listing; that is something that your client would need to handle.
不幸的是,MLSD/MLST 命令在处理响应格式时,不能保证列表中文件的顺序;这是您的客户需要处理的事情。