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