Index | Thread | Search

From:
Ingo Schwarze <schwarze@usta.de>
Subject:
Re: mtime format in ls -l
To:
tech@openbsd.org
Cc:
Jan Stary <hans@stare.cz>, Crystal Kolipe <kolipe.c@exoticsilicon.com>
Date:
Fri, 16 Jan 2026 19:59:32 +0100

Download raw body.

Thread
Hello,

Crystal Kolipe wrote on Fri, Jan 16, 2026 at 12:38:40PM +0000:
> On Fri, Jan 16, 2026 at 12:24:37PM +0100, Jan Stary wrote:

>> The long format of ls -l is documented as follows:
>> 
>>    If the -g, -l, or -n options are given, the following information is
>>    displayed for each file: mode, number of links, owner (though not for
>>    -g), group, size in bytes, time of last modification ("mmm dd HH:MM"),
>>    and the pathname.
>> 
>> The mtime format only seems to be 'mmm dd HH:MM', as in 'Sep 15 13:08',
>> for files with mtime less than six months ago. For older files, it becomes
>> 'mmm dd  yyyy', as in 'Feb 11  2025'.

> The year field is not guaranteed to be limited to four characters.
> 
> If you create a file with year > 9999, then the field expands to the right.
> 
> If you create a file with year < 0, then the field can be prefixed with a
> minus sign.
> 
> If you create a file with -1000 < year < 0, then the field is padded
> to THREE digits with a leading minus sign.
> 
> Although /usr/bin/touch will not allow the user to create such timestamps,
> it is trivial my other means, including extracting files with such wild
> timestamps from archives, etc.
> 
> Since the details from the manual page could be used by people writing
> scripts that parse the output of 'ls -l', it should not imply that the
> output strictly conforms to 'mmm dd  yyyy' without further qualification.

I think this is a case where being less specific is more valuable:
being less specific conveys a feeling to the reader that the output
is mainly intended for human consumption.  Also, being very specific
has little value as simply running ls(1) in an arbitrary directory
makes it clear how the output looks (roughly, in usual cases).

So, here is what i propose; OK?
  Ingo


Index: ls.1
===================================================================
RCS file: /cvs/src/bin/ls/ls.1,v
diff -u -r1.79 ls.1
--- ls.1	24 Oct 2016 13:46:58 -0000	1.79
+++ ls.1	16 Jan 2026 18:47:59 -0000
@@ -281,8 +281,7 @@
 .Fl g ) ,
 group,
 size in bytes,
-time of last modification
-.Pq Dq mmm dd HH:MM ,
+date and time or date and year of last modification,
 and the pathname.
 In addition, for each directory whose contents are displayed, the first
 line displayed is the total number of blocks used by the files in the