Newsgroups: comp.unix.internals Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!wuarchive!uunet!rbj From: rbj@uunet.uu.net (Root Boy Jim) Subject: Re: easy for some Message-ID: <1991May17.183827.10306@uunet.uu.net> Organization: UUNET Communications Services, Falls Church, VA References: <6686@male.EBay.Sun.COM> Date: Fri, 17 May 1991 18:38:27 GMT In article <6686@male.EBay.Sun.COM> matthew@gizmo.UK.Sun.COM (Matthew Buller - Sun EHQ - MIS) writes: > >I am fairly new to unix, and I have a minor question:- >problem: to extract text between start and end patterns in a file > >I have tried to grok the man page for `sed' but no luck. Try a bit harder. Or buy a book such a "Sed & Awk" from O'Reilly & Associates. In the meantime, here is the solution: sed -n '/pat1/,/pat2/p' also sed '/pat1/,/pat2/!d' Be aware that this will select all non-overlapping ranges, so you may get more than you want. Basicly, all the lines in the sed 'program' are executed on every line of the input file. It's really pretty simple. However, my eyes glazed over the first time I read the words "pattern space". -- [rbj@uunet 1] stty sane unknown mode: sane