sed question
Rouben Rostamian
rouben at math16.math.umbc.edu
Thu May 16 14:35:10 AEST 1991
In article <3880 at wb3ffv.ampr.org> wmark at 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
}' <filename
--
Rouben Rostamian Telephone: (301) 455-2458
Department of Mathematics and Statistics e-mail:
University of Maryland Baltimore County bitnet: rostamian at umbc.bitnet
Baltimore, MD 21228, U.S.A. internet: rouben at math9.math.umbc.edu
More information about the Comp.unix.shell
mailing list