From: Al Aab <af137@freenet.toronto.on.ca> ============================ seders newsletter #2 ============================== SED PROBLEM #1 There was that arcane language called BASIC. Here is a statement in BASIC :- DRAW "U" : IF P THEN DRAW " U u DLrR D LRR D R LL " : GOTO L The problem is to beautify the input, using a general sed script, by removing the blanks between the second double-quote pair. The result should be: DRAW "U" : IF P THEN DRAW "UUDLRDLRRRDRLL" : GOTO L - + - SED PROBLEM #2 Given a book divided into big chapters, each chapter may be too big to fit in sed's RAM buffers (the pattern space & the hold space). Each chapter starts with a line of 3 dashes, chapter n, and another 3 dashes. How can you select all the chapters that contain "pattern"? Here is a sample input file to work with: ---cut here--------------------------------------------------------------------- --- chapter 1 --- ... pattern -- line 1.1 line 1.2 --- chapter 2 --- line 2.1 pattern @#$ line 2.2 --- chapter 3 --- line 3.1 line 3.2 --- chapter 4 --- line 4.1 line 4,2 !#@$pattern(*&^ ---cut here--------------------------------------------------------------------- I posted the above problem to comp.editor, comp.unix.programmer, comp.unix.questions and maybe comp.unix.wizards. In sed, I have yet to get a satisfactory answer, but did get some interesting ones: From Berlin, Germany: Use agrep -k From Austria: Use csplit to split the input file into separate chapters, and grep to select the files that contain the pattern. I managed to solve that problem in 2 ways. One way using sed, sort, cat, tac. Another solution used about 3 lines of sed. Removing the constraint that the chapters may overflow sed buffers, I had come up with an earlier, easier sed solution. Send your solutions, ideas, insights, questions,etc. If you want to take over as seders coordinator, you're welcome. sed u soon al aab seders coordinator af137@torfree.net 20 August 1996 -- no dat v no c solution DAT v no c problema ========================= end of seders newsletter #2 ==========================