GNU bug report logs - #78910
tail does not support -r added by POSIX.1-2024

Previous Next

Package: coreutils;

Reported by: Collin Funk <collin.funk1 <at> gmail.com>

Date: Fri, 27 Jun 2025 05:37:03 UTC

Severity: normal

Full log


Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Collin Funk <collin.funk1 <at> gmail.com>
To: bug-coreutils <at> gnu.org
Subject: tail does not support -r added by POSIX.1-2024
Date: Thu, 26 Jun 2025 22:36:32 -0700
Creating this bug report since I have not been able to create a working
implementation yet, and perhaps my looking into this will inspire others
thoughts...

POSIX-1.2024 adds the following SYNOPSIS for 'tail' [1]:

    tail [-f] [-c number|-n number] [file]
    tail -r [-n number] [file]

Where the description for '-r' is:

    Copy the lines in reverse order (last line first). If -n is
    specified, that many lines of the file, starting with the last line,
    shall be copied. If -n is not specified, every line of the input
    file shall be copied.

In a simple implementation of 'tail', one that allocates an array to
store each line in memory, this would be easy to implement. However,
the Coreutils version reads the file in BUFSIZE/getpagesize() chunks
and then prints, repeating until completed. Therefore, we cannot just
modify the existing code to swap lines in memory.

Collin

[1] https://pubs.opengroup.org/onlinepubs/9799919799/utilities/tail.html




This bug report was last modified 38 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.