• Time-stamping files

    From Janis Papanagnou@3:633/10 to All on Saturday, November 14, 2026 09:13:50
    Occasionally I'm downloading a series of files, be it episodes of
    films, chapters of documents, etc., and I'm numbering the files with
    a name indicating the document and containing a sequence number 1..N
    and I want them also stored with ascending file system time-stamps.
    Given that I trigger my downloads in parallel I have to 'touch' the
    files in the correct order afterwards. So far the use case.

    What I lazily did was, say, touch name*.pdf but while the shell's
    file expansion lists sequentially name1.pdf name2.pdf ... name8.pdf
    the 'touch' command seems to _operate_ arguments in *reverse* order.

    It's no biggie, but I had been wondering about that behavior. I'd at
    least have expected an option available with 'touch' to control that,
    or that the files are handled sequentially as provided as arguments.

    I had thus written my own 'touchlist' script/hack to "fix" that. But
    I'd be curious about thoughts concerning that behavior of 'touch' (or alternative approaches).

    Janis


    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Kenny McCormack@3:633/10 to All on Saturday, November 14, 2026 09:28:46
    In article <11d957u$1fnqs$1@dont-email.me>,
    Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:
    ...
    I had thus written my own 'touchlist' script/hack to "fix" that. But
    I'd be curious about thoughts concerning that behavior of 'touch' (or >alternative approaches).

    I don't have any direct comment on the issue, since I suspect that your requirement is unique enough that you are just going to have to roll your
    own solution (as you have done).

    But I have 3 general comments/concerns:

    1) If you touch them on-masse, isn't there some risk that they all end
    up with the same timestamp - even if "touch" does re-calculate the
    current time for each file - on a sufficiently fast machine? What is
    the granularity of file timestamps on your system?

    2) If you use the shell to expand the list, won't you fall into the old
    "10 sorts before 2" problem?

    3) I'm surprised that the files aren't already time-stamped in the same
    order in which they were downloaded. Wouldn't that already be what you
    want?

    --
    The randomly chosen signature file that would have appeared here is more than 4-ish
    lines long. As such, it violates one or more Usenet RFCs. In order to remain in compliance with said RFCs, the actual sig can be found at the following URL:
    http://user.xmission.com/~gazelle/Sigs/Mandela

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Janis Papanagnou@3:633/10 to All on Saturday, November 14, 2026 12:10:01
    On 2026-11-14 10:28, Kenny McCormack wrote:
    But I have 3 general comments/concerns:

    1) If you touch them on-masse, isn't there some risk that they all end
    up with the same timestamp - even if "touch" does re-calculate the
    current time for each file - on a sufficiently fast machine? What is
    the granularity of file timestamps on your system?

    The granularity that 'stat' provides shows, e.g.: 13:43:00.056163913

    My script uses sub-seconds to distinguish the files, so if I have 5
    files they get a date/time setting of date-time.# where "#" are the sub-seconds. The granularity depends on the number of files (I'm
    evaluating "$#" and if I happen to have a list of, say, 200 files
    the sub-second resolution uses three digits hh:mm:ss.###).


    2) If you use the shell to expand the list, won't you fall into the old
    "10 sorts before 2" problem?

    I'm used to number sequences of such file-sets with leading zeroes,
    so I'll have with, say, 20 PDF files files name01.pdf ... name20.pdf.


    3) I'm surprised that the files aren't already time-stamped in the same
    order in which they were downloaded. Wouldn't that already be what you
    want?

    Yes, if they'd be strictly serialized on download. For the general
    case I'm using asynchronous downloads; I start a couple downloads in
    parallel and if the files are large it may happen that files with a
    higher serial number will be completed first; that may happen if the
    files are of different size or if one process overhauls another.

    If I can script all the download then I could use the plain 'touch',
    but often the sources are available through a website only, so I
    trigger the downloads from a browser and cannot directly control the
    arrival time.

    Besides these application cases I considered it worthwhile to have a
    script that just does what I want it to do; process the argument list
    so that the files get sorted the same way when I'm doing a "ls -ltr".

    Janis


    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Christian Weisgerber@3:633/10 to All on Saturday, November 14, 2026 17:35:45
    On 2026-11-14, Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:

    What I lazily did was, say, touch name*.pdf but while the shell's
    file expansion lists sequentially name1.pdf name2.pdf ... name8.pdf
    the 'touch' command seems to _operate_ arguments in *reverse* order.

    I think I've been surprised by cp(1) and/or mv(1) doing that, but
    not enough to verify or investigate. I expect such behavior could
    come out of fts(3), which those utilities use.

    BSD touch(1) operates in argument order. For 4.4BSD it didn't
    matter, because the time was fetched once and then applied to all
    arguments. Modern descendants now use utimensat(2) with UTIME_NOW.

    This is a utility whose implementation at any point in time was
    strongly influenced by the then available system calls. BSD versions
    from the 1980s used an actual read-write operation. The horror.

    --
    Christian "naddy" Weisgerber naddy@mips.inka.de

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Brian Patrie@3:633/10 to All on Sunday, November 15, 2026 04:11:05
    Janis Papanagnou wrote:
    Occasionally I'm downloading a series of files, be it episodes of
    films, chapters of documents, etc., and I'm numbering the files with
    a name indicating the document and containing a sequence number 1..N
    and I want them also stored with ascending file system time-stamps.
    Given that I trigger my downloads in parallel I have to 'touch' the
    files in the correct order afterwards. So far the use case.

    What I lazily did was, say, touch name*.pdf but while the shell's
    file expansion lists sequentially name1.pdf name2.pdf ... name8.pdf
    the 'touch' command seems to _operate_ arguments in *reverse* order.

    It's no biggie, but I had been wondering about that behavior. I'd at
    least have expected an option available with 'touch' to control that,
    or that the files are handled sequentially as provided as arguments.

    I had thus written my own 'touchlist' script/hack to "fix" that. But
    I'd be curious about thoughts concerning that behavior of 'touch' (or alternative approaches).

    The most obvious is, of course:

    for f in *
    do
    touch $f ; sleep .1
    done

    If heterogeneous number widths are an issue (and there are
    no screwy things like control characters in filenames,
    and you have GNU ls):

    ls --sort=version | while read f
    do
    touch $f ; sleep .1
    done

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Janis Papanagnou@3:633/10 to All on Sunday, November 15, 2026 12:17:35
    On 2026-11-15 11:11, Brian Patrie wrote:
    Janis Papanagnou wrote:
    Occasionally I'm downloading a series of files, be it episodes of
    films, chapters of documents, etc., and I'm numbering the files with
    a name indicating the document and containing a sequence number 1..N
    and I want them also stored with ascending file system time-stamps.
    Given that I trigger my downloads in parallel I have to 'touch' the
    files in the correct order afterwards. So far the use case.

    What I lazily did was, say,ÿÿ touch name*.pdfÿÿ but while the shell's
    file expansion lists sequentially name1.pdf name2.pdf ... name8.pdf
    the 'touch' command seems to _operate_ arguments in *reverse* order.

    It's no biggie, but I had been wondering about that behavior. I'd at
    least have expected an option available with 'touch' to control that,
    or that the files are handled sequentially as provided as arguments.

    I had thus written my own 'touchlist' script/hack to "fix" that. But
    I'd be curious about thoughts concerning that behavior of 'touch' (or alternative approaches).

    The most obvious is, of course:

    ÿ for f in *
    ÿ do
    ÿÿÿ touch $f ; sleep .1
    ÿ done

    If heterogeneous number widths are an issue (and there are
    no screwy things like control characters in filenames,
    and you have GNU ls):

    ÿ ls --sort=version | while read f
    ÿ do
    ÿÿÿ touch $f ; sleep .1
    ÿ done

    Thanks. - A few comments...

    GNU's "ls --sort=version" answers also point 2) in Kenny's post.
    (Although not necessary in my case it's good to remember it when
    necessary.)

    The "$f" should be quoted, at least to handle any spaces in filenames correctly. (Quoting should also prevent issues with control characters
    unless newlines spoil the 'while'-loop.) For the typical resources on
    the internet we should expect spaces in filenames, but quoting should
    be mandatory anyway.

    The "obvious" busy-wait with 'sleep' I wanted to avoid. With larger
    file lists the time may sum up annoyingly. (And why wait if you can
    just instantly "touch -d ..." with an artificial sub-seconds part.
    In this case you can write the date in a way that the series of files
    will get the same base-date with seconds resolution and the individual
    files only differ in the sub-seconds part that 'ls' will usually not
    show but implicitly use to sort the files by time if requested. That
    can of course also be implemented in your 'sleep'-based solution if
    the constant delay is adjusted to centi- or milliseconds depending on
    the number of files. Of course only if the used 'sleep' is supporting sub-second resolution. By that we could also guarantee that the summed
    up delay stays al least within 1 second which would be more acceptable
    WRT "UX".)

    Janis


    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Geoff Clare@3:633/10 to All on Monday, November 16, 2026 13:44:18
    Janis Papanagnou wrote:

    What I lazily did was, say, touch name*.pdf but while the shell's
    file expansion lists sequentially name1.pdf name2.pdf ... name8.pdf
    the 'touch' command seems to _operate_ arguments in *reverse* order.

    Which version of touch?

    POSIX requires that touch processes the files in the order they are
    given. (XCU 1.4 Utility Description Defaults, under "OPERANDS":
    "Unless otherwise stated, the standard utilities that accept operands
    shall process those operands in the order specified in the command
    line." The OPERANDS section for touch does not state otherwise.)

    Running GNU touch from coreutils 9.1 under strace on Linux shows it
    processes the files in the correct order...

    $ strace touch file? 2>&1 | grep 'file[0-9]'
    execve("/bin/touch", ["touch", "file1", "file2", "file3"], 0x7fff1d997dc8) = 0 openat(AT_FDCWD, "file1", O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK, 0666) = 3 openat(AT_FDCWD, "file2", O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK, 0666) = 0 openat(AT_FDCWD, "file3", O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK, 0666) = 0

    If your version of touch really is processing them in reverse, you
    should report it as a bug.

    --
    Geoff Clare <netnews@gclare.org.uk>

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Janis Papanagnou@3:633/10 to All on Monday, November 16, 2026 16:28:15
    On 2026-11-16 14:44, Geoff Clare wrote:
    Janis Papanagnou wrote:

    What I lazily did was, say, touch name*.pdf but while the shell's
    file expansion lists sequentially name1.pdf name2.pdf ... name8.pdf
    the 'touch' command seems to _operate_ arguments in *reverse* order.

    Which version of touch?

    $ whence touch
    /usr/bin/touch

    $ touch --version
    touch (GNU coreutils) 9.4
    ...


    POSIX requires that touch processes the files in the order they are
    given. (XCU 1.4 Utility Description Defaults, under "OPERANDS":
    "Unless otherwise stated, the standard utilities that accept operands
    shall process those operands in the order specified in the command
    line." The OPERANDS section for touch does not state otherwise.)

    Thanks.


    Running GNU touch from coreutils 9.1 under strace on Linux shows it
    processes the files in the correct order...

    [...]

    If your version of touch really is processing them in reverse, you
    should report it as a bug.

    Just noticed it's even worse than that. Incidentally I was able to
    cross the resolution boundary (which seems to be 8 ns on my system)
    by a single touch command which was

    $ touch 6 7 8 9

    and the 'stat' command for these four files shows

    2026-11-16 16:13:47.212143070 +0100 7
    2026-11-16 16:13:47.212143070 +0100 8
    2026-11-16 16:13:47.212143070 +0100 9
    2026-11-16 16:13:47.211143078 +0100 6 <<< ...78 ns

    $ ls -ltr 6 7 8 9
    -rw-rw-r-- 1 xyz xyz 0 Nov 16 16:13 6
    -rw-rw-r-- 1 xyz xyz 0 Nov 16 16:13 9
    -rw-rw-r-- 1 xyz xyz 0 Nov 16 16:13 8
    -rw-rw-r-- 1 xyz xyz 0 Nov 16 16:13 7


    Janis


    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Christian Weisgerber@3:633/10 to All on Monday, November 16, 2026 17:13:34
    On 2026-11-16, Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:

    $ touch --version
    touch (GNU coreutils) 9.4
    ...

    GNU touch has always processed its operands in command line order.
    Well, at least since 1992, which is as far as the Git repository
    goes back. So I don't see how we can blame userland for this:

    $ touch 6 7 8 9

    and the 'stat' command for these four files shows

    2026-11-16 16:13:47.212143070 +0100 7
    2026-11-16 16:13:47.212143070 +0100 8
    2026-11-16 16:13:47.212143070 +0100 9
    2026-11-16 16:13:47.211143078 +0100 6 <<< ...78 ns

    --
    Christian "naddy" Weisgerber naddy@mips.inka.de

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Keith Thompson@3:633/10 to All on Monday, November 16, 2026 16:01:16
    Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:
    Occasionally I'm downloading a series of files, be it episodes of
    films, chapters of documents, etc., and I'm numbering the files with
    a name indicating the document and containing a sequence number 1..N
    and I want them also stored with ascending file system time-stamps.
    Given that I trigger my downloads in parallel I have to 'touch' the
    files in the correct order afterwards. So far the use case.

    What I lazily did was, say, touch name*.pdf but while the shell's
    file expansion lists sequentially name1.pdf name2.pdf ... name8.pdf
    the 'touch' command seems to _operate_ arguments in *reverse* order.

    It's no biggie, but I had been wondering about that behavior. I'd at
    least have expected an option available with 'touch' to control that,
    or that the files are handled sequentially as provided as arguments.

    I haven't been able to reproduce this behavior on my system (Ubuntu).

    I built coreutils 9.4 from source and ran the resulting "touch" command
    with 100 arguments. "stat" shows the timestamps (mtime) increasing in
    command line order. The timestamp increases in increments of 1
    millisecond, so multiple files have the same timestamp, in groups of 14
    or 15 files.

    I had thus written my own 'touchlist' script/hack to "fix" that. But
    I'd be curious about thoughts concerning that behavior of 'touch' (or alternative approaches).

    If it were a problem, I'd probably just type

    for file in name*.pdf ; do touch "$file" ; done

    perhaps with a "sleep" if I want to ensure unique timestamps
    (I get 1-2 millisecond differences without a sleep on my system).
    There's nothing wrong with writing a script do that, but I probably
    wouldn't bother.

    My system (with an ext4 filesystem) stores timestamps with nanosecond
    precision (but not, apparently, nanosecond accuracy). Others
    might not. IIRC, FAT32 has 2-second precision.

    --
    Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
    void Void(void) { Void(); } /* The recursive call of the void */

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Kaz Kylheku@3:633/10 to All on Tuesday, November 17, 2026 01:05:41
    On 2026-11-16, Geoff Clare <geoff@clare.See-My-Signature.invalid> wrote:
    Janis Papanagnou wrote:

    What I lazily did was, say, touch name*.pdf but while the shell's
    file expansion lists sequentially name1.pdf name2.pdf ... name8.pdf
    the 'touch' command seems to _operate_ arguments in *reverse* order.

    Which version of touch?

    POSIX requires that touch processes the files in the order they are
    given.

    That's a terrible requirement. It should be required to touch all
    files passed as arguments in the same invocation to the same timestamp.

    Which can happen anyway for small numbers of arguments on a filesystem
    with sufficiently poor timestamp granularity.

    POSIX's requirement does not add up to a guarantee that the objects have increasing timestamps in the order given, so what's the point.

    --
    TXR Programming Language: http://nongnu.org/txr
    Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
    Mastodon: @Kazinator@mstdn.ca

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Janis Papanagnou@3:633/10 to All on Tuesday, November 17, 2026 07:55:37
    On 2026-11-17 01:01, Keith Thompson wrote:
    Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:
    Occasionally I'm downloading a series of files, be it episodes of
    films, chapters of documents, etc., and I'm numbering the files with
    a name indicating the document and containing a sequence number 1..N
    and I want them also stored with ascending file system time-stamps.
    Given that I trigger my downloads in parallel I have to 'touch' the
    files in the correct order afterwards. So far the use case.

    What I lazily did was, say, touch name*.pdf but while the shell's
    file expansion lists sequentially name1.pdf name2.pdf ... name8.pdf
    the 'touch' command seems to _operate_ arguments in *reverse* order.

    It's no biggie, but I had been wondering about that behavior. I'd at
    least have expected an option available with 'touch' to control that,
    or that the files are handled sequentially as provided as arguments.

    I haven't been able to reproduce this behavior on my system (Ubuntu).

    I built coreutils 9.4 from source and ran the resulting "touch" command
    with 100 arguments. "stat" shows the timestamps (mtime) increasing in command line order. The timestamp increases in increments of 1
    millisecond, so multiple files have the same timestamp, in groups of 14
    or 15 files.

    I had thus written my own 'touchlist' script/hack to "fix" that. But
    I'd be curious about thoughts concerning that behavior of 'touch' (or
    alternative approaches).

    If it were a problem, I'd probably just type

    for file in name*.pdf ; do touch "$file" ; done

    perhaps with a "sleep" if I want to ensure unique timestamps
    (I get 1-2 millisecond differences without a sleep on my system).

    It's unfortunately not guaranteed that you get different timestamps
    that way. (On my system I get regularly clashes, i.e. files with the
    same timestamps.) And 'sleep' I'd avoid for reasons given; certainly
    if we can comparably simply avoid these (as I've done with my script).

    There's nothing wrong with writing a script do that, but I probably
    wouldn't bother.

    My system (with an ext4 filesystem) stores timestamps with nanosecond precision (but not, apparently, nanosecond accuracy). Others
    might not. IIRC, FAT32 has 2-second precision.

    Given (also) my response to Geoff with the data from 'stat' and the
    "8 ns jump" of the timestamp I'm still puzzled what is going on here.
    (I quote it for completeness here, and *fixed* a crucial observation
    error I made; the difference is *not* 8 ns but rather already in the
    ms range, .2111... vs. .2121..., which I previously missed to see.)

    $ touch 6 7 8 9

    and the 'stat' command for these four files shows

    2026-11-16 16:13:47.211143078 +0100 6 ___________ gap of
    2026-11-16 16:13:47.212143070 +0100 7 ~1 ms
    2026-11-16 16:13:47.212143070 +0100 8
    2026-11-16 16:13:47.212143070 +0100 9

    $ ls -ltr 6 7 8 9
    -rw-rw-r-- 1 xyz xyz 0 Nov 16 16:13 6
    -rw-rw-r-- 1 xyz xyz 0 Nov 16 16:13 9
    -rw-rw-r-- 1 xyz xyz 0 Nov 16 16:13 8
    -rw-rw-r-- 1 xyz xyz 0 Nov 16 16:13 7

    A couple things are to observe here. Files 7, 8, and 9 have the same
    timestamp but are ordered sequentially anyway. "What" is responsible
    for the listing order given in "ls -t" (and "ls -tr") that they are
    presented in an order that cannot be explained by the timestamp alone.
    Then, between _groups_ of identical timestamps, here {6} and {7, 8, 9} respectively there is an ordering (i.e. {6} comes before {7, 8, 9}).
    So one question is whether files with the same timestamps will group
    correctly "in the order of the arguments" (POSIX) but only while the
    timestamps are incidentally unequal.

    And the new question arises - which component is responsible, if not
    'touch' - and whether the file system might also play a role here.
    (My file system is ZFS, if that matters.)

    While I think there's a point in Kaz' view
    "It should be required to touch all files passed as arguments in
    the same invocation to the same timestamp."
    I consider it nonetheless sensible to have a visible differentiation
    (as POSIX seems to require) in case we explicitly want 'ls' by time.

    Given all that I think that my scripting approach is sensible, to
    give all files of my single touch call the same timestamp [with sec
    resolution] and differentiate them anyway by setting the sub-seconds
    for a visible ordering by time. (Where using explicit 'sleep' calls
    I think is, for various reasons, not a good choice.)

    Now, in which order does 'ls -t' sorts a set of files which have the
    property of carrying the _same timestamp_ then; by name?

    Janis


    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Richard Harnden@3:633/10 to All on Tuesday, November 17, 2026 16:10:01
    On 14/11/2026 08:13, Janis Papanagnou wrote:
    Occasionally I'm downloading a series of files, be it episodes of
    films, chapters of documents, etc., and I'm numbering the files with
    a name indicating the document and containing a sequence number 1..N
    and I want them also stored with ascending file system time-stamps.
    Given that I trigger my downloads in parallel I have to 'touch' the
    files in the correct order afterwards. So far the use case.

    What I lazily did was, say,ÿÿ touch name*.pdfÿÿ but while the shell's
    file expansion lists sequentially name1.pdf name2.pdf ... name8.pdf
    the 'touch' command seems to _operate_ arguments in *reverse* order.

    It's no biggie, but I had been wondering about that behavior. I'd at
    least have expected an option available with 'touch' to control that,
    or that the files are handled sequentially as provided as arguments.

    I had thus written my own 'touchlist' script/hack to "fix" that. But
    I'd be curious about thoughts concerning that behavior of 'touch' (or alternative approaches).

    Janis


    It's not shell, but maybe this does what you want ...

    Starts with 'now' and zero usec, and adds 1 usec per file.
    Assuming you don't really care what the timestamps are, only that they increase.

    (I tried with 'echo * | xargs -l touch' too, but that doesn't work)

    #include <time.h>
    #include <sys/time.h>

    int main(int argc, char *argv[])
    {
    struct timeval times[2];

    times[0].tv_sec = time(NULL);
    times[1].tv_sec = times[0].tv_sec;

    times[0].tv_usec = 0;
    times[1].tv_usec = 0;

    for (int i=1; i<argc; i++)
    {
    if ( utimes(argv[i], times) != 0 )
    return 1;

    times[0].tv_usec += 1;
    times[1].tv_usec += 1;
    }

    return 0;
    }






    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Keith Thompson@3:633/10 to All on Tuesday, November 17, 2026 13:40:18
    Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:
    On 2026-11-17 01:01, Keith Thompson wrote:
    Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:
    Occasionally I'm downloading a series of files, be it episodes of
    films, chapters of documents, etc., and I'm numbering the files with
    a name indicating the document and containing a sequence number 1..N
    and I want them also stored with ascending file system time-stamps.
    Given that I trigger my downloads in parallel I have to 'touch' the
    files in the correct order afterwards. So far the use case.

    What I lazily did was, say, touch name*.pdf but while the shell's
    file expansion lists sequentially name1.pdf name2.pdf ... name8.pdf
    the 'touch' command seems to _operate_ arguments in *reverse* order.

    It's no biggie, but I had been wondering about that behavior. I'd at
    least have expected an option available with 'touch' to control that,
    or that the files are handled sequentially as provided as arguments.

    I haven't been able to reproduce this behavior on my system (Ubuntu).
    I built coreutils 9.4 from source and ran the resulting "touch"
    command with 100 arguments. "stat" shows the timestamps (mtime)
    increasing in command line order. The timestamp increases in
    increments of 1 millisecond, so multiple files have the same
    timestamp, in groups of 14 or 15 files.

    I had thus written my own 'touchlist' script/hack to "fix" that. But
    I'd be curious about thoughts concerning that behavior of 'touch' (or
    alternative approaches).

    If it were a problem, I'd probably just type
    for file in name*.pdf ; do touch "$file" ; done
    perhaps with a "sleep" if I want to ensure unique timestamps
    (I get 1-2 millisecond differences without a sleep on my system).

    It's unfortunately not guaranteed that you get different timestamps
    that way. (On my system I get regularly clashes, i.e. files with the
    same timestamps.) And 'sleep' I'd avoid for reasons given; certainly
    if we can comparably simply avoid these (as I've done with my script).

    I don't think you had said that you wanted unique timestamps.

    What you get with `touch 0 1 2` is that 0 is no newer than 1 and
    1 is no newer than 2 (where "newer" is defined by the mtime). Any
    two, or all three, can have the same timestamp if they're touched
    more quickly than the clock updates.

    I think you were observing the output of `ls -tr` and *incorrectly*
    assuming that it indicated that, for example, 0 is newer than 1,
    when in fact 0 and 1 have the same timestamp, but `ls -tr` uses
    some other criterion to decide how to sort them.

    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.

    Note that newer Ubuntu releases use uutils, the Rust reimplementation
    of coreutils. It's *supposed* to work the same way. You might
    consider other implementations as well (*BSD, busybox, toybox)
    depending on how much you care about portability.

    `touch a b c` appears to guarantee that the timestamps satisfy
    a <= b <= c. If you require a < b < c, you'll need to do a little
    more work.

    GNU coreutils touch lets you specify the timestamp you want. A script
    that touches each of a list of files with a unique timestamp could start
    with the current time, and increment it by one nanosecond for each file.
    This assumes the filesystem supports nanosecond-resolution timestamps
    (not all do).

    POSIX specifies the `-d` option to touch and allows fractional seconds,
    but it doesn't specify how many digits are significant.

    [...]

    --
    Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
    void Void(void) { Void(); } /* The recursive call of the void */

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Nuno Silva@3:633/10 to All on Tuesday, November 17, 2026 23:56:42
    On 2026-11-17, Keith Thompson wrote:

    Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:
    On 2026-11-17 01:01, Keith Thompson wrote:
    Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:
    Occasionally I'm downloading a series of files, be it episodes of
    films, chapters of documents, etc., and I'm numbering the files with
    a name indicating the document and containing a sequence number 1..N
    and I want them also stored with ascending file system time-stamps.
    Given that I trigger my downloads in parallel I have to 'touch' the
    files in the correct order afterwards. So far the use case.

    What I lazily did was, say, touch name*.pdf but while the shell's
    file expansion lists sequentially name1.pdf name2.pdf ... name8.pdf
    the 'touch' command seems to _operate_ arguments in *reverse* order.

    It's no biggie, but I had been wondering about that behavior. I'd at
    least have expected an option available with 'touch' to control that,
    or that the files are handled sequentially as provided as arguments.

    I haven't been able to reproduce this behavior on my system (Ubuntu).
    I built coreutils 9.4 from source and ran the resulting "touch"
    command with 100 arguments. "stat" shows the timestamps (mtime)
    increasing in command line order. The timestamp increases in
    increments of 1 millisecond, so multiple files have the same
    timestamp, in groups of 14 or 15 files.

    I had thus written my own 'touchlist' script/hack to "fix" that. But
    I'd be curious about thoughts concerning that behavior of 'touch' (or
    alternative approaches).

    If it were a problem, I'd probably just type
    for file in name*.pdf ; do touch "$file" ; done
    perhaps with a "sleep" if I want to ensure unique timestamps
    (I get 1-2 millisecond differences without a sleep on my system).

    It's unfortunately not guaranteed that you get different timestamps
    that way. (On my system I get regularly clashes, i.e. files with the
    same timestamps.) And 'sleep' I'd avoid for reasons given; certainly
    if we can comparably simply avoid these (as I've done with my script).

    I don't think you had said that you wanted unique timestamps.

    What you get with `touch 0 1 2` is that 0 is no newer than 1 and
    1 is no newer than 2 (where "newer" is defined by the mtime). Any
    two, or all three, can have the same timestamp if they're touched
    more quickly than the clock updates.

    I think you were observing the output of `ls -tr` and *incorrectly*
    assuming that it indicated that, for example, 0 is newer than 1,
    when in fact 0 and 1 have the same timestamp, but `ls -tr` uses
    some other criterion to decide how to sort them.

    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>

    Note that newer Ubuntu releases use uutils, the Rust reimplementation
    of coreutils. It's *supposed* to work the same way. You might
    consider other implementations as well (*BSD, busybox, toybox)
    depending on how much you care about portability.

    `touch a b c` appears to guarantee that the timestamps satisfy
    a <= b <= c. If you require a < b < c, you'll need to do a little
    more work.

    GNU coreutils touch lets you specify the timestamp you want. A script
    that touches each of a list of files with a unique timestamp could start
    with the current time, and increment it by one nanosecond for each file.
    This assumes the filesystem supports nanosecond-resolution timestamps
    (not all do).

    POSIX specifies the `-d` option to touch and allows fractional seconds,
    but it doesn't specify how many digits are significant.

    [...]

    --
    Nuno Silva

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Keith Thompson@3:633/10 to All on Tuesday, November 17, 2026 16:08:47
    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.

    --
    Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
    void Void(void) { Void(); } /* The recursive call of the void */

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Kaz Kylheku@3:633/10 to All on Wednesday, November 18, 2026 06:19:04
    On 2026-11-17, Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:
    Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:
    On 2026-11-17 01:01, Keith Thompson wrote:
    Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:
    Occasionally I'm downloading a series of files, be it episodes of
    films, chapters of documents, etc., and I'm numbering the files with
    a name indicating the document and containing a sequence number 1..N
    and I want them also stored with ascending file system time-stamps.
    Given that I trigger my downloads in parallel I have to 'touch' the
    files in the correct order afterwards. So far the use case.

    What I lazily did was, say, touch name*.pdf but while the shell's
    file expansion lists sequentially name1.pdf name2.pdf ... name8.pdf
    the 'touch' command seems to _operate_ arguments in *reverse* order.

    It's no biggie, but I had been wondering about that behavior. I'd at
    least have expected an option available with 'touch' to control that,
    or that the files are handled sequentially as provided as arguments.

    I haven't been able to reproduce this behavior on my system (Ubuntu).
    I built coreutils 9.4 from source and ran the resulting "touch"
    command with 100 arguments. "stat" shows the timestamps (mtime)
    increasing in command line order. The timestamp increases in
    increments of 1 millisecond, so multiple files have the same
    timestamp, in groups of 14 or 15 files.

    I had thus written my own 'touchlist' script/hack to "fix" that. But
    I'd be curious about thoughts concerning that behavior of 'touch' (or
    alternative approaches).

    If it were a problem, I'd probably just type
    for file in name*.pdf ; do touch "$file" ; done
    perhaps with a "sleep" if I want to ensure unique timestamps
    (I get 1-2 millisecond differences without a sleep on my system).

    It's unfortunately not guaranteed that you get different timestamps
    that way. (On my system I get regularly clashes, i.e. files with the
    same timestamps.) And 'sleep' I'd avoid for reasons given; certainly
    if we can comparably simply avoid these (as I've done with my script).

    I don't think you had said that you wanted unique timestamps.

    What you get with `touch 0 1 2` is that 0 is no newer than 1 and
    1 is no newer than 2 (where "newer" is defined by the mtime). Any
    two, or all three, can have the same timestamp if they're touched
    more quickly than the clock updates.

    I'd much more readily get behind the requirement that 0, 1 and 2
    have identical timestamps. At least, if they are each on a filesystem supporting the same resolution of timestamp. (That is to say, the
    current time is sampled once, and converted into the time stamp format supported by each of the argument objects, which may cause it to be
    truncated differently, but any two objects that are on the same,
    or same kind of filesystem should end up with identical modification
    times.)

    touch has that -r <ref-object> option which can achieve a facsimile
    of these requirements, if the script creates a temporary file,
    uses it as a reference and then deletes it.

    touch without the -r option would ideally behave the same way as with
    -r, except using a single sample of the system time as the reference.

    The one infelicity in such an requirement is that it's limited by the
    argument passing limits. As soon as you use "xargs" to break up a long
    touch command line, the all-stamps-same property is lost; you have to
    resort to the -r <ref-object> option.

    --
    TXR Programming Language: http://nongnu.org/txr
    Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
    Mastodon: @Kazinator@mstdn.ca

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Janis Papanagnou@3:633/10 to All on Wednesday, November 18, 2026 08:28:04
    On 2026-11-17 17:10, Richard Harnden wrote:
    On 14/11/2026 08:13, Janis Papanagnou wrote:
    [...]

    I had thus written my own 'touchlist' script/hack to "fix" that. But
    I'd be curious about thoughts concerning that behavior of 'touch' (or
    alternative approaches).

    It's not shell, but maybe this does what you want ...

    Starts with 'now' and zero usec, and adds 1 usec per file.
    Assuming you don't really care what the timestamps are, only that they increase.

    Thanks.

    This - the C-algorithm below - is actually similar to what my shell
    script does. The difference is that you're counting micro-seconds
    (always as a fixed increment) where I'm adjusting it to the needs
    (with the least possible accuracy); I wanted to keep the counter as
    close to the seconds as possible.

    For comparison, here's the Kornshell script[*] that I'm using...


    typeset -i n_files=$#
    typeset -i decimals=${#n_files}
    typeset -i serial_no=0
    typeset -Z${decimals} subseconds
    typeset time_now

    printf "%(%Y-%m-%d %H:%M:%S)T" | IFS= read time_now
    for f in "$@"
    do
    subseconds=$(( ++serial_no ))
    touch -d "${time_now}.${subseconds}" "${f}"
    done


    An argument list up to 999 files will still stay in the [ms] range,
    a handful of file (less than 10) will be represented by time-now.#,
    100000 files will require with time-now.###### the range of [æs],
    where the '#' symbols represent the sub-seconds decimals.

    [...]
    Janis

    [*] To rewrite, e.g. for Bash, note...

    typeset -i declares an integer variable
    typeset -Z{n} declares a numeric variable with n digits (you may
    replace that with printf '%0*d' $n $subsec in Bash)
    printf "%(...)T" is a built-in time generator/formatter (may be
    replaced by the external 'date ...' instead)
    ... | read var would not work in Bash that way, use $(...) e.g.



    #include <time.h>
    #include <sys/time.h>

    int main(int argc, char *argv[])
    {
    ÿÿÿ struct timeval times[2];

    ÿÿÿ times[0].tv_sec = time(NULL);
    ÿÿÿ times[1].tv_sec = times[0].tv_sec;

    ÿÿÿ times[0].tv_usec = 0;
    ÿÿÿ times[1].tv_usec = 0;

    ÿÿÿ for (int i=1; i<argc; i++)
    ÿÿÿ {
    ÿÿÿÿÿÿÿ if ( utimes(argv[i], times) != 0 )
    ÿÿÿÿÿÿÿÿÿÿÿ return 1;

    ÿÿÿÿÿÿÿ times[0].tv_usec += 1;
    ÿÿÿÿÿÿÿ times[1].tv_usec += 1;
    ÿÿÿ }

    ÿÿÿ return 0;
    }







    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Janis Papanagnou@3:633/10 to All on Wednesday, November 18, 2026 08:47:17
    On 2026-11-17 22:40, Keith Thompson wrote:
    Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:
    On 2026-11-17 01:01, Keith Thompson wrote:
    Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:
    Occasionally I'm downloading a series of files, be it episodes of
    films, chapters of documents, etc., and I'm numbering the files with
    a name indicating the document and containing a sequence number 1..N
    and I want them also stored with ascending file system time-stamps.
    Given that I trigger my downloads in parallel I have to 'touch' the
    files in the correct order afterwards. So far the use case.

    What I lazily did was, say, touch name*.pdf but while the shell's
    file expansion lists sequentially name1.pdf name2.pdf ... name8.pdf
    the 'touch' command seems to _operate_ arguments in *reverse* order.

    It's no biggie, but I had been wondering about that behavior. I'd at
    least have expected an option available with 'touch' to control that,
    or that the files are handled sequentially as provided as arguments.

    I haven't been able to reproduce this behavior on my system (Ubuntu).
    I built coreutils 9.4 from source and ran the resulting "touch"
    command with 100 arguments. "stat" shows the timestamps (mtime)
    increasing in command line order. The timestamp increases in
    increments of 1 millisecond, so multiple files have the same
    timestamp, in groups of 14 or 15 files.

    I had thus written my own 'touchlist' script/hack to "fix" that. But
    I'd be curious about thoughts concerning that behavior of 'touch' (or
    alternative approaches).

    If it were a problem, I'd probably just type
    for file in name*.pdf ; do touch "$file" ; done
    perhaps with a "sleep" if I want to ensure unique timestamps
    (I get 1-2 millisecond differences without a sleep on my system).

    It's unfortunately not guaranteed that you get different timestamps
    that way. (On my system I get regularly clashes, i.e. files with the
    same timestamps.) And 'sleep' I'd avoid for reasons given; certainly
    if we can comparably simply avoid these (as I've done with my script).

    I don't think you had said that you wanted unique timestamps.

    I wanted _ascending_ timestamps.

    The point is that with spurious 'sleep' delays you could get strange
    results; e.g. in the meantime downloaded files could get in-between.
    So the dates should be close together, and since I can do my counts
    in the sub-seconds parts the *nice* _side-effect_ is that the set of
    files will carry the same timestamp.


    What you get with `touch 0 1 2` is that 0 is no newer than 1 and
    1 is no newer than 2 (where "newer" is defined by the mtime). Any
    two, or all three, can have the same timestamp if they're touched
    more quickly than the clock updates.

    Yes, they can be the same or different (as said before; and see my
    previously posted 'stat' output example).


    I think you were observing the output of `ls -tr` and *incorrectly*
    assuming that it indicated that, for example, 0 is newer than 1,
    when in fact 0 and 1 have the same timestamp, but `ls -tr` uses
    some other criterion to decide how to sort them.

    Yes and no. As seen in my previously posted data the files with the
    same internal timestamp are ordered, of course not by the timestamp
    but by something else; may it be the name, or the physical position
    in the directory, or whatever; that order is *also* affected by the
    '-r'. So me have some mixture, primary search criterion is the time,
    and the secondary criterion isn't clear to me.


    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.

    Yes, that's one possibility. (It's just not transparent which one
    it actually is.)


    Note that newer Ubuntu releases use uutils, the Rust reimplementation
    of coreutils. It's *supposed* to work the same way. You might
    consider other implementations as well (*BSD, busybox, toybox)
    depending on how much you care about portability.

    Well, I have my simple script solution. ;-)


    `touch a b c` appears to guarantee that the timestamps satisfy
    a <= b <= c. If you require a < b < c, you'll need to do a little
    more work.

    Yes.


    GNU coreutils touch lets you specify the timestamp you want. A script
    that touches each of a list of files with a unique timestamp could start
    with the current time, and increment it by one nanosecond for each file.

    I think I very early already mentioned that my script does something
    like that (or even something better). :-)

    This assumes the filesystem supports nanosecond-resolution timestamps
    (not all do).

    That's why I stay as close to the seconds as possible. (For a handful
    of files one decimal is sufficient, for 999 files [ms] suffice, and
    with 100000 files you enter the [æs] resolution.)


    POSIX specifies the `-d` option to touch and allows fractional seconds,
    but it doesn't specify how many digits are significant.

    Yes, that's what I've been using in my script. - I suppose that the
    supported resolution may depend on the filesystem.

    Janis


    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Janis Papanagnou@3:633/10 to All on Wednesday, November 18, 2026 08:49:56
    On 2026-11-18 00:56, Nuno Silva wrote:
    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>

    Thanks for digging that up! :-)

    (Makes all further speculations unnecessary.)

    Janis

    [...]


    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Janis Papanagnou@3:633/10 to All on Wednesday, November 18, 2026 08:59:35
    On 2026-11-18 08:47, Janis Papanagnou wrote:
    [...]

    The point is that with spurious 'sleep' delays you could get strange
    results; e.g. in the meantime downloaded files could get in-between.
    So the dates should be close together, and since I can do my counts
    in the sub-seconds parts the *nice* _side-effect_ is that the set of
    files will carry the same timestamp.

    What I wanted to say...

    [...] will carry the _same visible_ timestamp when inspected with
    the 'ls' command [while being still able to sort them by time].

    Janis

    [...]


    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Nuno Silva@3:633/10 to All on Wednesday, November 18, 2026 10:56:43
    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

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Keith Thompson@3:633/10 to All on Wednesday, November 18, 2026 15:19:43
    Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:
    On 2026-11-17 22:40, Keith Thompson wrote:
    [...]
    I don't think you had said that you wanted unique timestamps.

    I wanted _ascending_ timestamps.

    The point is that with spurious 'sleep' delays you could get strange
    results; e.g. in the meantime downloaded files could get in-between.
    So the dates should be close together, and since I can do my counts
    in the sub-seconds parts the *nice* _side-effect_ is that the set of
    files will carry the same timestamp.

    What you get with `touch 0 1 2` is that 0 is no newer than 1 and
    1 is no newer than 2 (where "newer" is defined by the mtime). Any
    two, or all three, can have the same timestamp if they're touched
    more quickly than the clock updates.

    Yes, they can be the same or different (as said before; and see my
    previously posted 'stat' output example).

    Hmm. I would interpret "_ascending_ timestamps" to mean a < b < c.
    If all you need is a <= b <= c, I'd describe that as non-descending
    timestamps.

    I think you were observing the output of `ls -tr` and *incorrectly*
    assuming that it indicated that, for example, 0 is newer than 1,
    when in fact 0 and 1 have the same timestamp, but `ls -tr` uses
    some other criterion to decide how to sort them.

    Yes and no. As seen in my previously posted data the files with the
    same internal timestamp are ordered, of course not by the timestamp
    but by something else; may it be the name, or the physical position
    in the directory, or whatever; that order is *also* affected by the
    '-r'. So me have some mixture, primary search criterion is the time,
    and the secondary criterion isn't clear to me.

    Just to be clear, there are no separate internal and external
    timestamps. A file's mtime is, on my system, stored with nanosecond resolution. `ls -t` or `ls -tr` uses the full nanosecond-precise
    timestamp as the primary sort key (and the name as the secondary
    key when two files have the same precise mtime). `make` uses the
    full precision timestamp when deciding which of two files is newer.
    And so on.

    `ls -l` simply doesn't display the fractional part of the mtime.
    `ls -l --full-time` does, as does `stat`.

    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.

    Yes, that's one possibility. (It's just not transparent which one
    it actually is.)

    As discussed elsethread, that behavior seems to be required by Posix.

    It would be nice, I suppose, if you could use the timestamp, oldest
    first, as the primary key, and the name, not reversed, as the
    secondary key, but ls doesn't have options to do that. (And I'm
    not suggesting it should.)

    [...]

    POSIX specifies the `-d` option to touch and allows fractional
    seconds, but it doesn't specify how many digits are significant.

    Yes, that's what I've been using in my script. - I suppose that the
    supported resolution may depend on the filesystem.

    In particular, FAT32 has 2-second resolution, so if you try to create
    1000 files with distinct timestamps, they'll range over more than 8
    minutes.

    --
    Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
    void Void(void) { Void(); } /* The recursive call of the void */

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Brian Patrie@3:633/10 to All on Thursday, November 19, 2026 03:56:56
    Janis Papanagnou wrote:
    The "$f" should be quoted

    Oops. zsh user. I often forget to portablize that. :)

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)