285

Something annoying about ls -l command is it shows only hour and minute for a file(like 08:30). How can I see the second portion(like 08:30:44)?

man 1 ls and search for 'second' does not give any clue.

Jimm Chen
  • 5,904

6 Answers6

317

Does your version of ls support the --time-style option? If so:

ls -la --time-style=full-iso blah

-rw-r--r-- 1 root root 0 2011-11-08 18:02:08.954092000 -0700 blah
Gareth
  • 18,809
matt
  • 3,356
  • 1
  • 15
  • 2
  • 11
    Yes, thanks, even on a old Mandrake Linux 10.0 from year 2005. --full-time OK as well. – Jimm Chen Nov 09 '11 at 02:08
  • 1
    or "ls -ale" (only this worked for me on an older linux distro) – mBardos Jul 20 '16 at 13:02
  • 16
    Mac OSX equivalent: ls -lT – MarkHu Jan 25 '17 at 00:49
  • 1
    What is the difference between --time-style=full and --time-style=full-iso? – neverMind9 Jun 10 '19 at 14:51
  • @neverMind9 That's the same. You can even use --time-style=f for the same effect. full-iso is the full name, other unambiguous short names can also be used. The TIME_STYLE argument can be full-iso, long-iso, iso, locale, or +FORMAT. – pallxk Jul 23 '20 at 07:42
  • 1
    Now we can clearly see that after all these years ssh/sshfs STILL doesn't support sub-second time stamps! https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=971645 – CR. Aug 26 '21 at 22:48
151

The more simple way is:

ls --full-time

which is equal to

ls -l --time-style=full-iso

If you want to show entries as hidden files starting with ., add -a:

ls --full-time -a
zhouji
  • 1,611
  • What is the difference between --time-style=full and --time-style=full-iso? – neverMind9 Jun 10 '19 at 14:50
  • @neverMind9 There is no difference. The value is internaly expanded from full to full-iso. Same happens e.g. to f. It does not work for l or lo, because they could be long-iso or locale. But lon will expand to long-iso – huha Aug 11 '22 at 08:30
52

For OS X, it looks like the best you get is:

ls -l -T

From the ls(1) manpage on 10.10.5:

-T When used with the -l (lowercase letter ``ell'') option, display complete time information for the file, including month, day, hour, minute, second, and year.

natevw
  • 758
29

An alternative to the approved answer - you can use a custom format like in the date command if "--time-style=full-iso" output is too detailed for you:

ls -l --time-style=+"%b %d %Y %H:%M:%S" blah
-rw-rw-r-- 1 root root 0 Feb 03 2014 01:13:01 blah
gensec
  • 291
5

On BusyBox systems, ls -e works fine!

HeySora
  • 103
AsynKc
  • 69
3

For BSD systems including FreeBSD and macOS, it would be:

ls -la -D '%Y-%m-%dT%H:%M:%S'
miken32
  • 559
AndiDog
  • 646