Thread (19 messages) flat view 19 messages, 7 authors, 2021-03-15

Re: [PATCH v3 (resend)] tee: Add -q, --quiet, --silent option to not write to stdout

From: Alejandro Colomar (man-pages) <hidden>
Date: 2021-01-24 16:23:16

On 1/24/21 5:11 PM, Teran McKinney wrote:
On 2021-01-24 13-18-46    , Alejandro Colomar wrote:
quoted
This is useful for using tee to just write to a file,
at the end of a pipeline,
without having to redirect to /dev/null

Example:

echo 'foo' | sudo tee -q /etc/foo;

is equivalent to the old (and ugly)

echo 'foo' | sudo tee /etc/foo >/dev/null;

Signed-off-by: Alejandro Colomar <redacted>
---
[...]
Hi,

Why is this a thing?

The point of tee is to write a file *and* to stdout. If you don't want use that, use:

`> file`

To overwrite.

Or

`>> file`

To append.

I guess the only reason this would be used is if you wanted to write
multiple files at the same time, which tee supports.

-Teran

Hi Teran,

The rationale is that protected files can't be modified with '>', unless
you give superuser rights to the whole shell.  If you want fine-grained
control over the rights of the tools in the pipeline, you'll come to
times where you want the write step to be the only one to have those,
and you can't [sudo >] nor [sudo >>], which by the way I would consider
an even better solution, but which would require much more work, and
designing a completely new idiom for it, which would face much more
objection too.

Regards,

Alex

-- 
Alejandro Colomar
Linux man-pages comaintainer; https://www.kernel.org/doc/man-pages/
http://www.alejandro-colomar.es/
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help