Example usage :
mtee 'cat > /tmp/passwd1' 'grep a > /tmp/passwd2' 'grep b > /tmp/passwd3' < /etc/passwd...this constructs three pipelines, all running against the same stdin read once, and written 3 times, all independent of each other aside from running against the same input data.
Another form of usage:
$ cat commands head -2 grep foo grep bar $ cat /etc/passwd | ./mtee --serial --file /tmp/commands 'grep blech' Creating 4 pipes popening command 0: head -2 popening command 1: grep foo popening command 2: grep bar popening command 3: grep blech root:x:0:0:root:/root:/bin/bash daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
And a third:
$ ps auxww | mtee --quiet --serial 'head -1' 'grep mtee' USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND dstromb+ 32328 0.0 0.0 27820 7108 pts/10 R+ 10:22 0:00 python3 /usr/local/bin/mtee --quiet --serial head -1 grep mtee
The help message looks like:
/usr/local/bin/mtee sets up multiple pipes and sends a copy of stdin to each of them Usage: /usr/local/bin/mtee [--file file_of_commands1] [--help] [--] command1 command2 ... commandn --help shows this help message -- signals the end of options, so that commands may start with a "-" --file filename reads commands to set up pipes with, one command per line May be repeated. --quiet says to operate quietly --serial says to process the pipes serially, big inhale into virtual memory, use only for small inputs commandx says to use commandx to set up a pipe
Dec 9, 2020:
Verbose operation no longer outputs two newlines per line for --file.
Eliminated two rare quadratic performance issues.
Dec 8, 2020:
--help writes to stdout.
Oct 24 2005:
Modified to allow use of "-f filename" to read a list of commands from filename
Mar 9, 2005:
Modified to use 1 megabyte blocks, instead of lines. It's now much
faster on large files.
You can e-mail the author with questions or comments: