On Thursday 21 November 2024 02:16:48 pm Greg Wooledge wrote:
> On Thu, Nov 21, 2024 at 19:55:04 +0100, to...@tuxteam.de wrote:
> > On Thu, Nov 21, 2024 at 06:44:37PM +0000, Darac Marjal wrote:
> > 
> > [...]
> > 
> > > If it helps, "sponge" (in the moreutils package) seems to offer the right
> > > interface here:
> > 
> > [...]
> > 
> > Oh, wow -- thanks for that little gem!
> 
> For the record, sponge -a doesn't actually append to the original
> file.  As the man page says,
> 
>     -a
> 
>     Replace the file with a new file that contains the file's original
>     content, with the standard input appended to it. This is done
>     atomically when possible.
> 
> 
> hobbit:~$ ls -li y
> 847514 -rw-r--r-- 1 greg greg 8 Nov 21 07:18 y
> hobbit:~$ echo quux | sponge -a y
> hobbit:~$ ls -li y
> 6684744 -rw-r--r-- 1 greg greg 13 Nov 21 14:11 y
> 
> The inode number changed, because it's a new file.  This may be desirable
> or not -- it all depends on your needs.  If the file in question is a log
> file that some program may still be writing to, then this is absolutely
> NOT desirable.
 
Why would you want to append to a file that some other program is also writing 
to?  Sounds messy...


-- 
Member of the toughest, meanest, deadliest, most unrelenting -- and
ablest -- form of life in this section of space,  a critter that can
be killed but can't be tamed.  --Robert A. Heinlein, "The Puppet Masters"
-
Information is more dangerous than cannon to a society ruled by lies. --James 
M Dakin

Reply via email to