Article View: comp.unix.shell
Article #390Re: Time-stamping files
From: Keith Thompson
Date: Tue, 17 Nov 2026 00:01
Date: Tue, 17 Nov 2026 00:01
44 lines
3210 bytes
3210 bytes
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 */
Technical Details
Message-ID:
<11dg5gc$3vgth$3@kst.eternal-september.org>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!kst.eternal-september.org!.POSTED!not-for-mailReferences:
<11d957u$1fnqs$1@dont-email.me>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!kst.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson <Keith.S.Thompson+u@gmail.com> Newsgroups: comp.unix.shell Subject: Re: Time-stamping files Date: Mon, 16 Nov 2026 16:01:16 -0800 Organization: None to speak of Lines: 44 Message-ID: <11dg5gc$3vgth$3@kst.eternal-september.org> References: <11d957u$1fnqs$1@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain Injection-Date: Tue, 17 Nov 2026 00:01:17 +0000 (UTC) Injection-Info: kst.eternal-september.org; logging-data="4178865"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18hn4owy8ED8rd1REp9aBHR"; posting-host="4d09bcb88bf90e94e5f0c615814a2a57" User-Agent: Gnus/5.13 (Gnus v5.13) Cancel-Lock: sha1:M0MLywKIGVvpZS5cEdm+fQJYXDI= sha256:xHzhm8avIBALXHOF3aCwMJCWggX4wssP7124WLm/A6k= sha1:ttZYgXAouYQ1a9XQ5Tw4UWdOoZI= sha256:fNlGp84z3kyGQWME6vcFAy6lhXGH8qbsrI4pKgc8NbE=