OS X's built-in ls
command does not take time formatting arguments, but the stat
command takes strftime format strings so you can get an approximation of what you want by doing:
stat -l -t '%FT%T' *
The %FT%T
produces an ISO8601 local timestamp. Add a %z
if you want a UTC offset.
But while the timestamp is right, the rest only approximates what you'd get from ls. For instance, ls -l
properly aligns fields into columns, can colorize output, and of course it lists directory contents rather than requiring you to pass all filenames as arguments. You can at least reproduce the proper alignment by piping the output through tr
to convert all spaces into tabs:
stat -l -t '%F%T' * | tr ' ' \\t
Alternatively, I think it should be possible to get ls -l
to produce an ISO8601 timestamp by defining a custom locale, but I have not seen it done.
ls
seems to offer nothing for formatting datetimes, other than changing timezone and sorting by datetime rather than alpha. developer.apple.com/library/mac/documentation/Darwin/Reference/…