Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!husc6!cmcl2!rutgers!labrea!aurora!ames!sdcsvax!ucsdhub!hp-sdd!hplabs!gatech!emory!arnold From: arnold@emory.uucp (Arnold D. Robbins {EUCC}) Newsgroups: comp.windows.misc Subject: Re: Icons, pipes, etc. Message-ID: <2187@emory.uucp> Date: Fri, 31-Jul-87 17:18:54 EDT Article-I.D.: emory.2187 Posted: Fri Jul 31 17:18:54 1987 Date-Received: Sun, 2-Aug-87 08:48:08 EDT References: <8705190042.AA14664@cogsci.berkeley.edu> <9954@decwrl.DEC.COM> <66@laura.irb.informatik> <409@sugar.UUCP> <165@xyzzy.UUCP> Reply-To: arnold@emory.UUCP (Arnold D. Robbins {EUCC}) Organization: Emory University Computing Center Lines: 42 In article <165@xyzzy.UUCP> throopw@xyzzy.UUCP (Wayne A. Throop) writes: > >> peter@sugar.UUCP (Peter da Silva) >> [...] you can describe some pipelines graphically that you would have a great >> deal of trouble expressing on a command line. >> >> (awk)_______ _(one set of lines) >> \__(sort both together)|(grep2)_/ >> (sort|grep)_/ \_(another set of lines) >> >> Every now and then I come across something wierd like this I want to do. >> I usually end up making temp files. Wasn't that the whole point of pipes >> in the first place? > > [Wayne gives an involved solution using tee and multiple file descriptors.] There exists a notation to do this in ksh-i, the latest version of ksh. To use it though, your Unix must have the V8 /dev/fd mechanism (keep an eye on comp.sources.unix for a driver for 4.3 & NFS systems, from me, originally from Fred Blonder). Anyway the notation is sort (awk) (sort | grep) The ()'s enclose a shell pipeline, if preceded by a '<' or left alone, the pipline's output is connected to a file in /dev/fd passed as the argument to the program. The file will be the read end of a pipe, so sort would see, e.g., "/dev/fd/4" and "/dev/fd/5" for its arguments, awk and the sort|grep pipeline would write on the other side of the pipe. Such a pipeline may be written to as well: command | tee >(prog1) >(prog2) would send command's output to both prog1 and prog2. There is no existing Unix tool that corresponds to the 'grep2' in Peter's example above. -- Arnold Robbins ARPA, CSNET: arnold@emory.ARPA BITNET: arnold@emory UUCP: { decvax, gatech, sun!sunatl }!emory!arnold ONE-OF-THESE-DAYS: arnold@emory.mathcs.emory.edu