From owner-freebsd-questions@FreeBSD.ORG Sun Jan 9 03:30:09 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 2F8C6106564A for ; Sun, 9 Jan 2011 03:30:09 +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 BF0D78FC0C for ; Sun, 9 Jan 2011 03:30:08 +0000 (UTC) Received: by wwf26 with SMTP id 26so18357574wwf.31 for ; Sat, 08 Jan 2011 19:30:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:date:message-id :subject:from:to:content-type; bh=0yh4QDrasEOTM5u6kmEB4rirwAWTPQ/EOVLGzB+V7OQ=; b=P5Z569eqsBZp9UKzvanF52QHZQA7qlUZ95FQSL3n5K/lCNGIIIcxC72++VADEFeCul k9bqRbIauWyxg4OAPe5X4L5ph9Ep93G9bu4Ks8BWWYDfv/9lcKakbFSGvNvz9qrF1ND7 tDa1PmRxOuoSbttGGRuekhRM0Ln1vHO7sNWxI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=jxfH5Dvi6JCUsZbMVG5JDvbwhhyYAT7SpWa5iWfpHd3z2FvL/Q/DdmBMFO9lW7Ra5+ kCmcDx1/WnayPGRdPt/8NS+w+UdZVv9yip42D097lOwjz8jioHNCAeIXt7LGI2vAhgxD wkbX0D1ehxjLnOwv0yns+CtKI5lfUPH13kuEk= MIME-Version: 1.0 Received: by 10.227.146.9 with SMTP id f9mr1329697wbv.209.1294543807621; Sat, 08 Jan 2011 19:30:07 -0800 (PST) Received: by 10.227.20.73 with HTTP; Sat, 8 Jan 2011 19:30:07 -0800 (PST) Date: Sat, 8 Jan 2011 20:30:07 -0700 Message-ID: From: Modulok To: "questions@freebsd.org" Content-Type: text/plain; charset=ISO-8859-1 Cc: Subject: 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: Sun, 09 Jan 2011 03:30:09 -0000 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-