我使用来自PuTTY的PuTTY和-ls选项将目录列表通过STDOUT获得到perl脚本。
我得到的输出是:
Listing directory /path/to/my/directory
drwxr-sr-x 2 234 11 4096 Feb 4 11:11 .
drwxrwxrwx 21 root root 4096 Jan 28 17:50 ..
-rw-r--r-- 1 root 11 415570 Jan 10 12:27 009800D2-10003ACC.log
-rw-r--r-- 1 root 11 131072 Dec 15 09:59 MCP.20101215_095929_644.snapshot.log
-rw-r--r-- 1 root 11 131072 Jan 19 13:32 MCP.20110119_133211_032.snapshot.log
-rw-r--r-- 1 root 11 10240105 Feb 2 22:32 MCP.20110202_173304_750.log
-rw-r--r-- 1 root 11 10240077 Feb 3 04:07 MCP.20110202_223257_159.log
-rw-r--r-- 1 root 11 10240094 Feb 3 06:29 MCP.20110203_040754_861.log
-rw-r--r-- 1 root 11 10240095 Feb 3 07:43 MCP.20110203_062936_730.log
-rw-r--r-- 1 root 11 10240066 Feb 3 10:20 MCP.20110203_074353_058.log然而,日期/时间的格式是一个痛苦的工作。理想情况下,我希望它是2011-02-04 10:02:33,而不是‘`Feb 4 10:02’。主要的问题是没有年份或秒。
是否有指定日期/时间格式的方法?
发布于 2011-02-04 16:28:53
为什么不直接使用plink.exe来远程执行"ls“命令呢?
有大量ls命令行开关将按您的意愿格式化输出。此外,您还可以远程将其输出输送到awk、sed等。
plink.exe user@remotehost "ls -l --full-time /my/remote/directory
发布于 2011-02-04 17:35:39
我不能评论,使用plink是最好的方法,我只是建议使用--time-style="+%Y-%m-%d %H:%M:%S"而不是--full-time,它可以让您摆脱秒后显示的不需要的东西。
https://serverfault.com/questions/231223
复制相似问题