Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!think.com!zaphod.mps.ohio-state.edu!wuarchive!uunet!mcsun!ukc!warwick!nott-cs!piaggio!anw From: anw@maths.nott.ac.uk (Dr A. N. Walker) Newsgroups: comp.unix.shell Subject: Re: sed question Message-ID: <1991May21.105728.21388@maths.nott.ac.uk> Date: 21 May 91 10:57:28 GMT References: <3880@wb3ffv.ampr.org> <1991May16.043510.16184@umbc3.umbc.edu> <1991May17.002433.15615@vpnet.chi.il.us> Reply-To: anw@maths.nott.ac.uk (Dr A. N. Walker) Organization: Maths Dept., Nott'm Univ., UK. Lines: 16 In article <1991May17.002433.15615@vpnet.chi.il.us> dattier@vpnet.chi.il.us (David W. Tamkin) writes: > sed -n '/PATTERN1/,/PATTERN2/p > /PATTERN2/q' filename Try sed '/PATTERN1/,$ !d; /PATTERN2/ q' filename which works even if PATTERN2 happens to occur before PATTERN1, and which mentions PATTERN2 only once [less to maintain!]. -- Andy Walker, Maths Dept., Nott'm Univ., UK. anw@maths.nott.ac.uk