How can I get the ls command to show an exact time?
4 Answers
Might depend on your distro, but this argument for ls
is available in Debian:
--time-style=STYLE
with -l, show times using style STYLE: full-iso, long-iso, iso,
locale, +FORMAT. FORMAT is interpreted like `date'; if FORMAT
is FORMAT1<newline>FORMAT2, FORMAT1 applies to non-recent files
and FORMAT2 to recent files; if STYLE is prefixed with `posix-',
STYLE takes effect only outside the POSIX locale
try
man ls
from your command line
-
--time-style
and--full-time
are specific to GNU ls, so they're available on every Linux (except some embedded distributions) and few other unices. Oct 28, 2010 at 23:41 -
@Gilles, moreover,
--time-style
is absent in busybox,--full-time
in this sense better to use.– 0andriyOct 10, 2019 at 13:09
Your locale will affect the way ls
displays that date and time.
My locale is en_US.UTF-8
and ls
always displays hours and minutes when I use ls -l
, for example. However, if I change my locale like this:
LC_TIME=C ls -l
files that are newer than six months old don't show a year, older than six months or are in the future don't display a time at all and do show the year. The C
locale (aka the POSIX
locale) reproduces the historical behavior of ls
in this regard (I seem to recall that there were some additional subtleties, however).
In FreeBSD the -T flag does this
ls -alFT
-rwxrwxr-x 1 un un 4900 May 5 10:52:03 2013 custom-banner.js*