Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using pscp.exe from PuTTY with the -ls option to get a directory listing via STDOUT to a perl script.

The output I get is this:

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

However, the format of the date/time is a pain to work with. Ideally I want it to be 2011-02-04 10:02:33 instead of `Feb 4 10:02'. The main problem is there is no year or seconds.

Is there a way to specify the date/time format?

share|improve this question
up vote 4 down vote accepted

Why dont you just use plink.exe instead to execute remotely the "ls" command ?

There are plenty of ls command-line switches that will format the output as you wish. Moreover, you can remotely pipe its output into awk, sed, etc.

plink.exe user@remotehost "ls -l --full-time /my/remote/directory

share|improve this answer
plink comes with PuTTY as does pscp – Renik Feb 4 '11 at 16:44
ah cool... I didn't think of using that! I've just tried it and it works fine. Thank you. – BG100 Feb 4 '11 at 16:55

I cannot comment, plink usage is the way to go, I just suggest using --time-style="+%Y-%m-%d %H:%M:%S" instead of --full-time, it gets you rid of the unwanted stuff displayed after the seconds

share|improve this answer
Thanks, but --full-time works fine. I'm using a perl regex to read the lines, so the unwanted stuff isn't a problem. It just gets ignored. – BG100 Feb 4 '11 at 17:55
Well, in that case nevermind :) – addam Feb 4 '11 at 20:47

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.