coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


From: Alejandro Colomar (man-pages)
Subject: Re: [PATCH v3 (resend)] tee: Add -q, --quiet, --silent option to not write to stdout
Date: Sun, 14 Mar 2021 10:44:30 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.0



On 1/25/21 5:03 AM, Bernhard Voelker wrote:
OTOH I understand that there's a little gap in the tool landscape.
Astonishingly, there doesn't seem to exist a trivial tool to redirect
from standard input (or any other input file descriptor) to a file.
I wrote such a little tool in the attached:

   $ src/sink --help
   Usage: src/sink [OPTION]... FILE
   Copy input stream to FILE.

   Mandatory arguments to long options are mandatory for short options too.

     -a, --append              append to the given FILE, do not overwrite
     -c, --create              ensure to create FILE, error if exists
     -i, --input-stream=FD     read from stream FD instead of standard input

   The default input stream number FD is 0, representing the standard input.

This allows not only to copy data from standard input, but from any
file descriptor open for reading.  It also allows control over
how the output file will be opened (e.g. with O_CREAT|E_EXCL).

The OPs case would look like:

   echo 'foo' | sudo sink /etc/foo
or
   echo 'foo' | sudo sink -a /etc/foo  # append.
or
   echo 'foo' | sudo sink -c /etc/foo  # ensure creation of the file.

I'm not sure if this will ever be considered for inclusion -
I just did it "for fun". ;-)

Have a nice day,
Berny


By chance, I just found out that there is a tool very similar to 'sink' in moreutils [1]. It's called 'sponge'.

[1]: <https://joeyh.name/code/moreutils/>

So this feature already exists, and therefore I drop my patches.

Cheers,

Alex

--
Alejandro Colomar
Linux man-pages comaintainer; https://www.kernel.org/doc/man-pages/
http://www.alejandro-colomar.es/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]