Alternative to the tee command without STDOUT

I'm using | sudo tee FILENAME to be able to write or append to a file for which superuser permissions are required quite often.

Although I understand why it is helpful in some situation, that tee also sends its input to STDOUT again, I never ever actually used that part of tee for anything useful. In most situations, this feature only causes my screen to be filled with unwanted jitter, if I don't go the extra step and manually silence it with tee 1> /dev/null.

My question: Is there is a command arround, which does exactly the same thing as tee, but does by default not output anything to STDOUT?


Another option that avoids piping the stuff back and then to /dev/zero is

sudo command | sudo dd of=FILENAME

The dd solution still prints junk to stderr:

$ ls | sudo dd of=FILENAME
0+1 records in
0+1 records out
459 bytes (459 B) copied, 8.2492e-05 s, 5.6 MB/s

That can be avoided using the status option:

command | sudo dd status=none of=FILENAME

Another interesting possibility (for Linux anyway):

command | sudo cp /dev/stdin FILENAME

To copy TTY input into a file, I often do this:

sudo cp /dev/tty FILENAME

It's too bad tee doesn't have an option to suppress stdout.


You could use a script. I.e. put something like this in i.e. $HOME/bin/stee, 0tee or similar:

#!/bin/bash

argv=
while [[ "$1" =~ ^- ]]; do
    argv+=" $1"
    shift
done

sudo tee $argv "$1" > /dev/null

#!/bin/bash

sudo tee "$@" > /dev/null

Make it executeable:

$ chmod 755 stee

Now do i.e.:

$ ls -la | stee -a /root/foo