Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 8 Jan 2011 20:30:07 -0700
From:      Modulok <modulok@gmail.com>
To:        "questions@freebsd.org" <questions@freebsd.org>
Subject:   Is there a 'Y' (i.e. branch) version of a command pipe?
Message-ID:  <AANLkTinhOLxthkGrZ309ZOnPpKux6FGyTbUtG5wOMqot@mail.gmail.com>

next in thread | raw e-mail | index | archive | help
List,

Is there a command that lets me send standard input to two different
places at the same time? (i.e. non-sequentially.) Think of it like a
pipe character, but with a 'Y' branch instead. Basically, I want to
record standard input to a log file, but also send it to another
command for processing.

For example, let's assume we have a command called 'branch' and it
copies standard input to the standard input of all arguments. We could
use it like this:

cat foo.txt | branch '/bin/echo > log1.txt' '/bin/echo > log2.txt'

The first 'cat' would read the file, pass it to our theoretical
'branch' command, which would then start two subprocesses, passing the
input to both of them. The result result would be two copies of the
file. (Obviously making copies of files is not my primary goal, just
an example.)

I guess another way of explaining it would be two write the same stdin
to two named pipes and then have two different programs read from each
pipe, getting the same output.

I can probably write something in Python, but thought I'd ask first. Thanks!
-Modulok-



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?AANLkTinhOLxthkGrZ309ZOnPpKux6FGyTbUtG5wOMqot>