On Thu, Nov 21, 2024 at 01:35:15PM +0100, to...@tuxteam.de wrote:
On Thu, Nov 21, 2024 at 07:22:53AM -0500, g...@wooledge.org wrote:
On Thu, Nov 21, 2024 at 09:48:06 +0100, to...@tuxteam.de wrote:

[...]

> My favourite is actually "sudo dd of=<file>" it hasn't the side effect
> of flooding your stdout (esp. with a larger, uglier thing).

Thanks for all the details :)

Typically you redirect tee's output to /dev/null.

Yes, that's what I always did and what actually motivated me
to search ("there must...").

Since the OP wanted to append, "tee -a" is a viable choice, but POSIX dd
doesn't have an append option.

Good point...

Checking my local Debian man pages now, however, I see that Debian's dd
(GNU coreutils) *does* offer an append option.

    dd oflag=append conv=notrunc of="$file"

So I guess that's another viable choice, as long as your target system
has GNU coreutils.

...since the >/dev/null looks less unattractive if you have all that
mouthful for dd. So for append, tee looks neater.

On the third hand, using here "dd" and there "tee" in a script for
the same thing... is not nice either. So if you have a mix of requirements,
yo're busted. Decissions, decissions...

In hindsight, it'd have been nice to give all those "filtering" utils a
"-o" option. Ship, sailed and things :-)

If it helps, "sponge" (in the moreutils package) seems to offer the right interface here:

  some command | sudo sponge [-a] file

The -a option appends sponge's stdin to the file instead of replacing the file.

--
For more information, please reread.

Attachment: signature.asc
Description: PGP signature

Reply via email to