Tell me more ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I want to make ls display time in ISO format (military format). How can I change this behavior?

On Linux I knew that I could force ls to display time in long format by usin --full-time but this doesn't work on OS X.

Update: I know that the format used by the command is based on the locale settings. The problem is that on OS X I was not able to use the trick of setting LC_TIME=en_DK.

share|improve this question
A non-answer, but still possibly useful: The stat(1) command is quite flexible and can be made to display time stamps in any desired format. – Harald Hanche-Olsen Jun 2 '11 at 14:45
gls (gnu ls) I mentioned in my answer can take a --style= flag where you can specify a +FORMAT string, so you can make the date appear whatever way you wish. – barryj Jun 3 '11 at 8:24

2 Answers

You can display time in the long format by using:

ls -lT

EDIT:

The above isn't quite what was wanted, but if you install gnu coreutils then gnu ls is available, which will do as required. If you use brew as a package manager, it's as simple as:

brew install coreutils
share|improve this answer
Thanks, this is useful but does not solve the problem. The full format used is still not ISO-8601. – Sorin Sbarnea Jun 2 '11 at 14:00
OK - you can install gnu coreutils which includes gnu ls, which will do what you want. Easiest way is one of brew, MacPorts or Fink. I use brew - so just running 'brew install coreutils' works. You'll then have gls available. – barryj Jun 2 '11 at 14:17

ls -l --time-style=iso works fine for me.

share|improve this answer

Your Answer

 
discard

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.