247

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.

2
  • These days ls -l shows second...for even higher granularity see some of the answers here... :")
    – rogerdpack
    Jun 30, 2021 at 16:57
  • 1
    @rogerdpack, not for me (bash)
    – Elliott
    Sep 6, 2021 at 0:28

6 Answers 6

270

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
  • 9
    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
  • 14
    Mac OSX equivalent: ls -lT
    – MarkHu
    Jan 25, 2017 at 0:49
  • What is the difference between --time-style=full and --time-style=full-iso?
    – neverMind9
    Jun 10, 2019 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, 2020 at 7:42
131

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
1
  • What is the difference between --time-style=full and --time-style=full-iso?
    – neverMind9
    Jun 10, 2019 at 14:50
49

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.

2
  • 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
23

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
4

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
  • Just for information, this also works with BusyBox on Android.
    – tomasz86
    Apr 9 at 10:23
1

For FreeBSD, it would be:

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.