Re: is there a way to use a work buffer in Linux bash? ...
On Tue, Dec 23, 2025 at 13:41:07 +0100, Nicolas George wrote:
> tomas@tuxteam.de (HE12025-12-23):
> > The buffer cache is actually pretty good at such things. You won't hit
> > disk too often
>
> It will not *read back* from the disk too often, but it will be
> *written* to disk very frequently; tmpfs avoids that.
I have absolutely no idea what Albretch is trying to do. So I'll
just address this tangent instead.
If you're using a temp file in a shell script, typically that temp
file is very short-lived. Almost always less than one second.
A temp file that's created, written to, read from, and deleted all
within such a short span of time will probably *not* be written to a
physical device. As long as you didn't do something silly like turning
on an "always flush" option in the file system mount options, and
you aren't using a network file system, the data are highly unlikely
to land on a disk.
There might be a write to update the *directory* metadata (mtime), since
the directory is modified once when creating a new file, and once when
unlinking the file. But that should be a quick, one-time operation long
after the file has been deleted. It might even be postponed long enough
that some *other* temp file in the same directory will cause a different
mtime update instead.
Of course, using a tmpfs ensures that there will never be a physical
write, even for mtime updates.
To the OP: please tell us WHAT YOU ARE TRYING TO DO. Specifically.
Reply to: