Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!sample.eng.ohio-state.edu!purdue!haven.umd.edu!umbc3.umbc.edu!math16.math.umbc.edu!rouben From: rouben@math16.math.umbc.edu (Rouben Rostamian) Newsgroups: comp.unix.shell Subject: Re: sed question Message-ID: <1991May16.043510.16184@umbc3.umbc.edu> Date: 16 May 91 04:35:10 GMT References: <3880@wb3ffv.ampr.org> Sender: newspost@umbc3.umbc.edu (News posting account) Organization: University of Maryland Baltimore County, Mathmatics Department Lines: 30 In article <3880@wb3ffv.ampr.org> wmark@wb3ffv.ampr.org (Mark Winsor) writes: >I know that > >sed -n '/PATTERN1/,/PATTERN2/p' filename > >will print everything between pattern 1 & 2, but what if I only want the >first occurence of these patterns in the file? I know I can pipe the above >statement to sed '/PATTERN2/q' but there has got to be a way to do this >in one sed process. Thanks. Here it is -- one sed process: sed -n -e ' /PATTERN1/,/PATTERN2/{ p :loop n /PATTERN2/!{ p bloop } p q }'