Xref: utzoo comp.unix.questions:6683 comp.unix.wizards:7984 Path: utzoo!mnetor!uunet!lll-winken!lll-lcc!ames!elroy!spl1!laidbak!daveb From: daveb@laidbak.UUCP (Dave Burton) Newsgroups: comp.unix.questions,comp.unix.wizards Subject: Re: A little help with SED please - clarifications. Message-ID: <1417@laidbak.UUCP> Date: 20 Apr 88 14:54:05 GMT References: <5490@sigi.Colorado.EDU> Reply-To: daveb@laidbak.UUCP (Dave Burton) Distribution: na Organization: is pretty bad/My method of Lines: 37 In article <5490@sigi.Colorado.EDU> murillo@boulder.Colorado.EDU (Rodrigo Murillo) writes: |I need an sed line (or some gory pipeline) to extract the data between |BEGIN and END. | >I have a text file of this form: | [... junk ...] | > BEGIN | > 1 | > 2 | > 3 | > END | [... junk ...] | > BEGIN | > 4 | > 5 | > 6 | > END | [... junk ...] |Add to that the fact that the data between BEGIN...END is really not |plain sequential numbers; it is random text. Sorry I was not more |clear. If you have a SED line to deal with the above, I would love to |see it. Thanks. Awk would be the tool of choice here. Your basic problem is that you have state in your text file (in,out), and the state changes only on subsequent lines. It is difficult (probably not impossible) to write a sed script, though an awk script is trivial. Try: awk ' /^BEGIN$/ { state = "in"; next } /^END$/ { state = "out"; next } { if (state == "in") print $0 } ' < yourfile -- --------------------"Well, it looked good when I wrote it"--------------------- Verbal: Dave Burton Net: ...!ihnp4!laidbak!daveb V-MAIL: (312) 505-9100 x325 USSnail: 1901 N. Naper Blvd. #include Naperville, IL 60540