277

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.

3
  • These days ls -l shows second...for even higher granularity see some of the answers here... :")
    – rogerdpack
    Jun 30, 2021 at 16:57
  • 2
    @rogerdpack, not for me (bash)
    – Elliott
    Sep 6, 2021 at 0:28
  • 1
    And for old files it shows the year, and not either the hour or minute!
    – nealmcb
    May 31 at 1:16

6 Answers 6

305

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
6
  • 11
    Yes, thanks, even on a old Mandrake Linux 10.0 from year 2005. --full-time OK as well.
    – Jimm Chen
    Nov 9, 2011 at 2:08
  • 1
    or "ls -ale" (only this worked for me on an older linux distro)
    – mBardos
    Jul 20, 2016 at 13:02
  • 16
    Mac OSX equivalent: ls -lT
    – MarkHu
    Jan 25, 2017 at 0:49
  • 1
    What is the difference between --time-style=full and --time-style=full-iso?
    – neverMind9
    Jun 10, 2019 at 14:51
  • 1
    Now we can clearly see that after all these years ssh/sshfs STILL doesn't support sub-second time stamps! bugs.debian.org/cgi-bin/bugreport.cgi?bug=971645
    – CR.
    Aug 26, 2021 at 22:48
146

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
2
  • What is the difference between --time-style=full and --time-style=full-iso?
    – neverMind9
    Jun 10, 2019 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, 2022 at 8: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.

3
  • 7
    Or like this: ls -lT.
    – jox
    Jun 8, 2017 at 21:19
  • this also works in Windows/Ubuntu
    – Michael
    Jul 22, 2017 at 17:11
  • 1
    You may want to take a closer look at that man page, specifically the -D option which was inherited from BSD and has been there forever.
    – miken32
    Apr 9 at 16:13
27

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
5

On BusyBox systems, ls -e works fine!

5
  • 4
    Which version of GNU coreutils do you use? With 8.20 I don't have this parameter.
    – sebix
    Nov 29, 2014 at 11:36
  • 2
    Version please :)
    – hakre
    Aug 6, 2015 at 7:31
  • 1
    When using GNU coreutils 8.22 ls there is no -e option. I suspect the version of ls you have is Darwin based. Aug 21, 2016 at 11:09
  • 3
    BusyBox. Embedded Linuxes. Yes. Try -e if these other (GNU based) flags fail.
    – Steven Lu
    Jan 5, 2017 at 17:04
  • 1
    Just for information, this also works with BusyBox on Android.
    – tomasz86
    Apr 9, 2022 at 10:23
3

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

ls -la -D '%Y-%m-%dT%H:%M:%S'

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .