Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!rutgers!mcdchg!ddsw1!dattier From: dattier@ddsw1.MCS.COM (David W. Tamkin) Newsgroups: comp.editors Subject: sed output Summary: two output files without truncation? Message-ID: <1991Feb20.234921.5738@ddsw1.MCS.COM> Date: 20 Feb 91 23:49:21 GMT Organization: Contributor Account at ddsw1, Wheeling, Illinois Lines: 23 Hmmm...this is knotty to explain... I'm running sed in a for loop (in sh) on several input files. Let's call them A, B, C, D, and E. The sed script should send output to three places. If I made a separate output file for each one, I'd finish with fifteen output files: Ax, Ay, Az, Bx, etc., through Ez. What I really want are a single x file, y file, and z file. When a sed script begins, sed scans for w operators and creates all target files needed. If files by those names already exist, tough; the old contents are clobbered. So if I use "w x" and "w y" in the script and redirect sed's stdout >>z, only z will have the proper contents; x and y will have only the extractions from input file E. I can use "w $i.x" and "w $i.y" (with proper quoting for the loop variable to be expanded) and then cat [A-E].x > x and cat [A-E].y > y afterward, but I'd rather lengthen the sed script than add the extra forks. Yes, I'm sure it can all be done in awk or perl, but I don't know them, don't do this stuff for a living, and certainly don't have the means or time or talent to learn awk or perl. Can sed be prevented from clobbering a file named in a w command? David Tamkin Box 7002 Des Plaines IL 60018-7002 708 518 6769 312 693 0591 MCI Mail: 426-1818 GEnie: D.W.TAMKIN CIS: 73720,1570 dattier@ddsw1.mcs.com