10

command in Linux

$ ls -lt --time-style=full-iso

output

...
-rw-r--r--  1 mduda mduda   1855 2009-08-26 13:07:55.000000000 +0200 screen-configurations.xml
drwxr-xr-x  2 mduda mduda   4096 2009-08-26 13:07:22.000000000 +0200 Documents
drwxr-xr-x  2 mduda mduda   4096 2009-08-26 13:07:22.000000000 +0200 Music
drwxr-xr-x  2 mduda mduda   4096 2009-08-26 13:07:22.000000000 +0200 Pictures
Mad_Dud
  • 268
  • 4
  • 10

3 Answers3

5

This comes close:

stat -l -t "%F %T %z" *

but without the sort, columns don't line up and the nanoseconds aren't included. Plus the syntax for file selection is different and other options for ls aren't available or are different.

This one might be closer:

find . -maxdepth 1 -printf "%M %n %-6u %-6g %6s %TY-%Tm-%Td %TT %TZ %f\n"|sort -k 9

In Mac OSX, gfind is needed (brew install gfind) (and note that the granularity will only be in whole seconds):

gfind . -maxdepth 1 -printf "%M %n %-6u %-6g %6s %TY-%Tm-%Td %TT %TZ %f\n"|sort -k 9

Rob Bednark
  • 215
  • 1
  • 2
  • 8
Dennis Williamson
  • 60,515
  • 14
  • 113
  • 148
  • Thanks for including a working time format string. In FreeBSD (i.e. TrueNAS) zsh ls, the command is `ls -alD"%F %T%z"` (like your example, but I removed the space before the timezone). – Colin Aug 13 '22 at 01:21
  • On macOS Catalina 10.15: `ls -alT`; there doesn't seem to be an option to format the time. – Colin Aug 13 '22 at 01:27
3

I know this is an old question, but if you're on OS X you can install coreutils to get the GNU version of ls, which includes the --time-style option:

brew install coreutils

Note that by default the utilities installed will be prefixed with g, so ls becomes gls.

shawkinaw
  • 151
  • 3
0
ls --full-time

works same as ls --time-style=full-iso

HBruijn
  • 72,524
  • 21
  • 127
  • 192