Date: Sun, 9 Jan 2011 18:08:46 -0700 From: Modulok <modulok@gmail.com> To: "questions@freebsd.org" <questions@freebsd.org> Subject: Re: Is there a 'Y' (i.e. branch) version of a command pipe? Message-ID: <AANLkTikxwpc_tiO8LhS=QyTZJWbnvysssieP3bOdKBWo@mail.gmail.com> In-Reply-To: <AANLkTinhOLxthkGrZ309ZOnPpKux6FGyTbUtG5wOMqot@mail.gmail.com> References: <AANLkTinhOLxthkGrZ309ZOnPpKux6FGyTbUtG5wOMqot@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On 1/8/11, Modulok <modulok@gmail.com> wrote: > 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- > Thanks guys! I'll look into the tee(1) command as suggested. You guys rock :) -Modulok-
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?AANLkTikxwpc_tiO8LhS=QyTZJWbnvysssieP3bOdKBWo>