Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: notesfiles Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!godot!harvard!seismo!hao!hplabs!hp-pcd!hpfcla!ajs From: ajs@hpfcla.UUCP (ajs) Newsgroups: net.sources Subject: Re: Mods to tee... Message-ID: <43600015@hpfcla.UUCP> Date: Thu, 17-Jan-85 20:34:00 EST Article-I.D.: hpfcla.43600015 Posted: Thu Jan 17 20:34:00 1985 Date-Received: Wed, 23-Jan-85 05:50:38 EST References: <350@rna.UUCP> Organization: Hewlett-Packard - Fort Collins, CO Lines: 34 Nf-ID: #R:rna:-35000:hpfcla:43600015:000:1630 Nf-From: hpfcla!ajs Jan 17 17:34:00 1985 > Basically the mods allow tee to accept shell pipeline commands as > descriptors to copy stdin to in addition to regular files... I hate to tell you this, but you didn't have to change tee to do it. (I hate to say so because (1) the proper solution is obscure and (2) I almost made the same changes myself before discovering it.) (And I'll tell you right here in net.sources, because this information just might prevent you from writing some unnecessary sources...) Anyway, awk(1) is already a very nice pipe splitter: awk '{ print | "first-pipeline"; print }' | second-pipeline You can do more than just split the data; you can also manipulate it in various wonderful ways as it goes through. You can set an awk variable to "first-pipeline", then reference it in several places: awk '{ ...; print "test" x | cmd; ...; print y | cmd; ...}' and only one instance of the pipeline will be created, to receive all the data in the order printed. You can even have awk write a shell script on the fly! How? Make cmd = "sh", and away you go. Why would you do that? Well, for one thing, it's a very nice way to, say, read a data file and mail various sections to various different people. (Hint: Use awk to pipe a shell script to "sh", which consists of a series of here-documents, surrounded by braces, piped to mail commands. For testing, set cmd = "cat > t" and look at file t afterwards to see what sh would have executed.) Awk: It's Not Just Another Ugly Program Alan Silverstein, Hewlett-Packard Fort Collins Systems Division, Colorado {ihnp4 | hplabs}!hpfcla!ajs, 303-226-3800 x3053, N 40 31'31" W 105 00'43"