How to have Linux ls command show second in time stamp

188

35

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

Posted 2011-11-09T00:47:57.773

Reputation: 4 129

Answers

199

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

matt

Posted 2011-11-09T00:47:57.773

Reputation: 2 176

1or "ls -ale" (only this worked for me on an older linux distro) – mBardos – 2016-07-20T13:02:39.253

11Mac OSX equivalent: ls -lT – MarkHu – 2017-01-25T00:49:41.300

What is the difference between --time-style=full and --time-style=full-iso? – neverMind9 – 2019-06-10T14:51:03.470

6Yes, thanks, even on a old Mandrake Linux 10.0 from year 2005. --full-time OK as well. – Jimm Chen – 2011-11-09T02:08:57.000

98

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

Posted 2011-11-09T00:47:57.773

Reputation: 1 081

What is the difference between --time-style=full and --time-style=full-iso? – neverMind9 – 2019-06-10T14:50:55.990

39

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

Posted 2011-11-09T00:47:57.773

Reputation: 531

3Or like this: ls -lT. – jox – 2017-06-08T21:19:36.080

this also works in Windows/Ubuntu – Michael – 2017-07-22T17:11:38.750

20

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

Posted 2011-11-09T00:47:57.773

Reputation: 201

3

Regarding to man ls instructions simply ls -e works fine !

AsynKc

Posted 2011-11-09T00:47:57.773

Reputation: 49

4Which version of GNU coreutils do you use? With 8.20 I don't have this parameter. – sebix – 2014-11-29T11:36:00.507

2Version please :) – hakre – 2015-08-06T07:31:39.553

1When using GNU coreutils 8.22 ls there is no -e option. I suspect the version of ls you have is Darwin based. – Elijah Lynn – 2016-08-21T11:09:38.717

1BusyBox. Embedded Linuxes. Yes. Try -e if these other (GNU based) flags fail. – Steven Lu – 2017-01-05T17:04:11.193

1

For FreeBSD, it would be:

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

AndiDog

Posted 2011-11-09T00:47:57.773

Reputation: 438