Path: utzoo!utgpu!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!uwmcsd1!marque!uunet!mcvax!hp4nl!botter!star.cs.vu.nl!maart From: maart@cs.vu.nl (Maarten Litmaath) Newsgroups: comp.unix.questions Subject: Re: a SED question Keywords: address-range, 2-addresses Message-ID: <1775@solo11.cs.vu.nl> Date: 6 Dec 88 20:24:44 GMT References: <32039@gt-cmmsr.GATECH.EDU> <1075@mtung.ATT.COM> Organization: V.U. Informatica, Amsterdam, the Netherlands Lines: 35 slj@mtung.ATT.COM (S. Luke Jones) writes: \Here is my problem: \ I have a file composed of multi-line records. \ Continuation lines begin with arbitrary white space. \ I want to extract *some* of the records. \for example: \ In this file, the "Here is my..." and "for example" lines \ begin multi-line records. Suppose the records I want \ are those that begin with an uppercase letter ("Here...") \ sed -n -e '/^[A-Z]/,/^[^(spc)(tab)]/p' file \ will print each such record, but would also get the "for..." \ line of the second record. \ sed -n -e '/^[A-Z]/,/^[(spc)(tab)]/p' file \ will not get "for..." but will only get the first following \ line that begins with white space. #! /bin/sh exec sed -n -e ' /^[A-Z]/{ : loop p n /^[ ]/b loop /^$/ b loop } ' $* -- fcntl(fd, F_SETFL, FNDELAY): |Maarten Litmaath @ VU Amsterdam: let's go weepin' in the corner! |maart@cs.vu.nl, mcvax!botter!maart