From: Al Aab <af137@freenet.toronto.on.ca> ============================= seders newsletter #3 ============================= I do not know if I should call this newsletter #3. Why? Coz I still have a lot of folloup to the previous newsletter and the contents of this newsletter is not much different from that of #2. Anyhow, I might call every email to seders a newsletter - easier on me & seders. Let us welcome a new seder: Felix von Leitner <leitner@math.fu-berlin.de>. He is also a friend of Herr Sven (http://www.math.fu-berlin.de/~guckes/sed/). It is a kleine, kleine world! I have amassed, off the net, more than a dozen sed-related items - mostly scripts. I am reluctant to reflect them to seders. Hate to flood your mailboxes, dear seders. But if i have explicit permission from any of you, then you will receive some of those goodies(?). If you don't complain, you'll receive more installements. Eventually, I will weed the stuff off my limited hard disk. I discovered a sed site in Berlin at http://www.math.fu-berlin.de/~guckes/sed/. I hope to convince Herr Sven to accommodate seders on his page. Lacking that, if any of you dear seders is willing of siting seders, let me know. Once, Mr Brian Ubben dreamed to me of his sed site fantasy. But a sooner sed site would be a boon. Plus, it will be a good prelude/excuse for me to retire from coordinateship. I am no spring chicken. - + - Today's sed problem is not much different from one in newsletter #2, although this time I enclosed a solution. seders are expected to shoot their solutions. I will reflect the best. For a document containing sections identifed by the string: ---,<section number>,--- create four output files containing: all the sections containing PATTERNa all the sections containing PATTERNb all the sections lacking PATTERNa all the sections lacking PATTERNb Here is the solution. Note that is does not guard against buffer overflow. It has been tested with sed15 (DOS). ---cut here--------------------------------------------------------------------- #n /^---$/!{H;$bextract;d;} N N :extract x /PATTERNa/w pa /PATTERNb/w pb /PATTERNa/!w npa /PATTERNb/!w npb /PATTERNa/!{/PATTERNb/!w npapb;} d ---cut here--------------------------------------------------------------------- A sample data file follows: ---cut here--------------------------------------------------------------------- --- 12.1 --- this chapter has PATTERNa .. this line does not This PATTERNa .. PATTERNa .. happens twice on same line --- 12.224 --- PATTERNa this section sports PATTERNb and PATTERNa .. many, many occurrences. --- 12.6 --- patternless section --- 99.00 --- but this also has patternb i mean PATTERNb ---cut here--------------------------------------------------------------------- -- no dat v no c solution DAT v no c problema ========================= end of seders newsletter #3 ==========================