Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pipe to multiple files, but not stdout

Tags:

bash

stdout

tee

I want to pipe stdout to multiple files, but keep stdout itself quiet. tee is close but it prints to both the files and stdout

$ echo 'hello world' | tee aa bb cc
hello world

This works but I would prefer something simpler if possible

$ echo 'hello world' | tee aa bb cc >/dev/null
like image 326
Zombo Avatar asked Mar 07 '13 07:03

Zombo


2 Answers

You can also close tee stdout output by writing to /dev/full

echo 'hello world' | tee aa bb cc >/dev/full

or by closing stdout.

echo 'hello world' | tee aa bb cc >&-

Be however aware that you will get either tee: standard output: No space left on device or tee: standard output: Bad file descriptor warnings.

like image 79
Jirka Avatar answered Sep 19 '22 12:09

Jirka


You can simply use:

echo 'hello world' | tee aa bb > cc 
like image 22
anishsane Avatar answered Sep 21 '22 12:09

anishsane