
02-26-2008
|
|
Shell programmer, author
|
|
|
Join Date: Mar 2007
Location: Toronto, Canada
Posts: 2,361
|
|
Quote:
Originally Posted by sank
Hi all,
I am using sed for extracting the lines that occurs between the 2 patterns using the following command:
sed -n '/pattern1/,/pattern2/' filename
The above command has no problem and works fine. But I was wondering if there is a way to quit sed when it has extracted the range at least once ? this is required because the file will have only one occurrence of the above pattern range and also the input file on which sed operates is big.
|
Code:
sed -n -e '/pattern1/,/pattern2/' -e '/pattern2/q' filename
|