Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!tellab5!vpnet!dattier From: dattier@vpnet.chi.il.us (David W. Tamkin) Newsgroups: comp.unix.shell Subject: Re: sed question Message-ID: <1991May17.002433.15615@vpnet.chi.il.us> Date: 17 May 91 00:24:33 GMT References: <3880@wb3ffv.ampr.org> <1991May16.043510.16184@umbc3.umbc.edu> Organization: VPnet Public Access Unix, Villa Park, Illinois 60181-2206 Lines: 33 rouben@math16.math.umbc.edu (Rouben Rostamian) wrote in <1991May16.043510.16184@umbc3.umbc.edu>: | 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 | }'