πŸš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.unix.shell
Article #405

Re: Time-stamping files

#405
From: Nuno Silva
Date: Wed, 18 Nov 2026 10:56
46 lines
3274 bytes
On 2026-11-18, Keith Thompson wrote:

> Nuno Silva <nunojsilva@invalid.invalid> writes:
>> On 2026-11-17, Keith Thompson wrote:
> [...]
>>> Reading the GNU coreutils ls documentation, I don't see any mention
>>> of how `ls -tr a b` orders its output when a and b have the same
>>> timestamp.  I speculate that if the timestamps are the same, it
>>> falls back to locale-specific alphabetical sorting -- and since
>>> the `-r` (`--reverse`) option was given, it sorts b before a.
>>> Someone could examine the source code.
>>
>> If it doesn't fall back to that, it should, at least if I'm reading
>> right. IEEE 1003.1-2008 says it should sort by "filename in the
>> collating sequence":
>>
>> Β«βˆ’t  Sort with the primary key being time modified (most recently
>>      modified first) and the secondary key being filename in the
>>      collating sequence. [...]Β»
>>
>> 2024 at opengroup.org has the same:
>> <https://pubs.opengroup.org/onlinepubs/9799919799/utilities/ls.html>
> [...]
>
> You're right.  POSIX does specifies that `ls -tr` uses the filename
> in the collating sequence as the secondary key.  The GNU coreutils
> documentation doesn't specify that (unless I missed something),
> but it does behave that way.

I think you didn't miss anything (here it's apparently missing from both
the man and info online manuals), and if a web version of the uutils
manpage is accurate, uutils also doesn't document this properly...
<https://uutils.org/coreutils/docs/utils/ls.html>:

    "-t Sort by modification time (the β€˜mtime’ in the inode), newest
        first."

BSD ls has different wording but mentions it (leaves out the part about
symbolic links, although maybe that's covered by the entry for -L?):
from <https://man.netbsd.org/ls.1>:

    "-t Sort by time modified (most recently modified first) before
        sorting the operands by lexicographical order."

-- 
Nuno Silva
Technical Details
Message-ID: <11dk09b$17u3r$1@dont-email.me>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.hispagatos.org!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail
References: <11d957u$1fnqs$1@dont-email.me> <11dg5gc$3vgth$3@kst.eternal-september.org> <11dgtp9$34tb9$3@dont-email.me> <11dihk2$q4aj$1@kst.eternal-september.org> <11dipjq$sq2d$2@dont-email.me> <11diqaf$telh$1@kst.eternal-september.org>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.hispagatos.org!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail
From: Nuno Silva <nunojsilva@invalid.invalid>
Newsgroups: comp.unix.shell
Subject: Re: Time-stamping files
Date: Wed, 18 Nov 2026 10:56:43 +0000
Organization: A noiseless patient Spider
Lines: 46
Message-ID: <11dk09b$17u3r$1@dont-email.me>
References: <11d957u$1fnqs$1@dont-email.me>
	<11dg5gc$3vgth$3@kst.eternal-september.org>
	<11dgtp9$34tb9$3@dont-email.me>
	<11dihk2$q4aj$1@kst.eternal-september.org>
	<11dipjq$sq2d$2@dont-email.me>
	<11diqaf$telh$1@kst.eternal-september.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 18 Nov 2026 10:56:45 +0000 (UTC)
Injection-Info: dont-email.me;
	logging-data="1308795"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1/km8msm17WCCBUB/EUbzCW"; posting-host="bb2916844079c4c5cbf31ba8357c0441"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)
Cancel-Lock: sha1:vaBj7HLMnwOOORDapXP07dHvL6w= sha256:d/V5JE0Ay0MCHDGpdbiabAtev5L5K1G3La4XFR2/i/w=
	sha1:8KDjz0fp1cO0D783kA/mY6vbmFI= sha256:Yv/xFjgsn1CuV/oalXuPR78Ob4J4cZh3K7NUxIpDfig=