From owner-freebsd-questions@FreeBSD.ORG Mon Jan 10 01:08:48 2011 Return-Path: Delivered-To: questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7B0D9106566C for ; Mon, 10 Jan 2011 01:08:48 +0000 (UTC) (envelope-from modulok@gmail.com) Received: from mail-ww0-f50.google.com (mail-ww0-f50.google.com [74.125.82.50]) by mx1.freebsd.org (Postfix) with ESMTP id 12F1D8FC12 for ; Mon, 10 Jan 2011 01:08:47 +0000 (UTC) Received: by wwf26 with SMTP id 26so18881624wwf.31 for ; Sun, 09 Jan 2011 17:08:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:content-type; bh=AyUGXJfEKUrU1e76KqFu7ZJ/UzOxo2nyWrf6oLKMafc=; b=PcM95BQDKnUxNhWPDXvoFYZFik9qPu4C75/3rl2wVsgeFNQTr+zlJgDQLPYr1Bxwv1 rDFKTAzbC/wRpeTfIVn/4v5y0dBM8k0HBmVvUi4SNaNYDVysjTvEajh8k/isdMKGRNkW 4iZPBuirlPqLz6XFrKbE4EdJAoKOHFluml8ck= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=KKMKXMLc5v07MoPhTuG3hnRLepIxnDQK+rn2hPcPv8fkCbK8r2Cx9auWQ0Vh9hQwJ+ jWvsGNpVCCG0Ny37pz4ax00b77S2DThdC1i2iWmTwfpyAAsAMSVZaEFCL09O721svwoZ MeMG09Yhl40dIEW+x8vYMWnOXPbYEVeaAHeLg= MIME-Version: 1.0 Received: by 10.227.155.145 with SMTP id s17mr18327708wbw.29.1294621726952; Sun, 09 Jan 2011 17:08:46 -0800 (PST) Received: by 10.227.20.73 with HTTP; Sun, 9 Jan 2011 17:08:46 -0800 (PST) In-Reply-To: References: Date: Sun, 9 Jan 2011 18:08:46 -0700 Message-ID: From: Modulok To: "questions@freebsd.org" Content-Type: text/plain; charset=ISO-8859-1 Cc: Subject: Re: Is there a 'Y' (i.e. branch) version of a command pipe? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Jan 2011 01:08:48 -0000 On 1/8/11, Modulok 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-