LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   how did the ls command display dates in old Linux versions? (https://www.linuxquestions.org/questions/linux-general-1/how-did-the-ls-command-display-dates-in-old-linux-versions-4175607071/)

stf92 05-31-2017 07:20 PM

how did the ls command display dates in old Linux versions?
 
Hi: how did the ls command display dates in old Linux versions? Did it use the month name? If you ask how old, take Linux 2.x.x. That's all.

ntubski 05-31-2017 07:45 PM

Quote:

Originally Posted by stf92 (Post 5717643)
Hi: how did the ls command display dates in old Linux versions?

Obligatory, it's GNU/Linux, not Linux ;)

But seriously, there is no reason for the kernel version to affect the format of date printed by ls. Perhaps you should check the coreutils NEWS file: http://git.savannah.gnu.org/cgit/cor....git/tree/NEWS, e.g.

Quote:

* Noteworthy changes in release 8.6 (2010-10-15) [stable]
[...]
ls -l now uses the traditional three field time style rather than
the wider two field numeric ISO style, in locales where a style has
not been specified. The new approach has nicer behavior in some
locales, including English, which was judged to outweigh the disadvantage
of generating less-predictable and often worse output in poorly-configured
locales where there is an onus to specify appropriate non-default styles.
[The old behavior was introduced in coreutils-6.0 and had been removed
for English only using a different method since coreutils-8.1]

jefro 05-31-2017 07:51 PM

I don't recall that it was different. Might have to look at old books or find an old man page?

Pretty sure you could find a floppy image or some old distro and run it in a vm to see. Thoms boot disk would have a minimal busybox but busybox versions may not act like stand alone programs.

stf92 05-31-2017 09:17 PM

Quote:

Originally Posted by ntubski (Post 5717649)
Obligatory, it's GNU/Linux, not Linux ;)

But seriously, there is no reason for the kernel version to affect the format of date printed by ls.

You are right. It can only depend on ls itself, assuming one uses always the same ls options. I'll try to make both date and ls -l to display date/times in the format DD-MM-YY HH:MM. By the way, cant you tell me what does "FORMAT is interpreted like 'date'" mean in ls man page? I quote:
Code:

      --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

EDIT: I think I now understand: +FORMAT is interpreted by this option in the same way as it is interpreted in the date command syntax.

jmccue 06-03-2017 08:40 AM

Since kernel 1.2.1 the same way as it does now, but I do not know if there was a way to change the format displayed

frankbell 06-03-2017 09:20 PM

I didn't know this before, but you can change the style of the date display by adding arguments to the ls command.

Code:

$ ls -l --time-style=long-iso
total 22036
-rw-r--r--  1 [username] users    25525 2015-08-10 10:09 akregator2015-08-10.xml
-rw-r--r--  1 [username] users    52114 2015-11-17 11:11 alberteinstein.jpg
-rw-r--r--  1 [username] users  412990 2015-11-17 11:10 alberteinstein.png
-rw-r--r--  1 [username] users    42388 2016-12-02 15:42 bc.txt
(snip)


ls -l --time-style=full-iso
total 22036
-rw-r--r--  1 [username] users    25525 2015-08-10 10:09:12.190836315 -0400 akregator2015-08-10.xml
-rw-r--r--  1 [username] users    52114 2015-11-17 11:11:25.545064156 -0500 alberteinstein.jpg
-rw-r--r--  1 [username] users  412990 2015-11-17 11:10:45.683063779 -0500 alberteinstein.png
-rw-r--r--  1 [username] users    42388 2016-12-02 15:42:52.641382333 -0500 bc.txt
(snip)

From the ls man page:

Quote:

--time-style=STYLE
with -l, show times using style STYLE: full-iso, long-iso, iso, locale, or +FORMAT; FORMAT is interpreted like in 'date'; if FORMAT is FORMAT1<newline>FORMAT2, then 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


All times are GMT -5. The time now is 07:25 AM.