Re: which command I should use to extract the matching part out
lina (lina.lastname@gmail.com on 2011-12-19 23:53 +0800):
> > sed -n '/^model 1/q;/^model 0/,$p'
>
> Just realize the sed -n '/model 0/,/model 1/'p can also do that. (so
> newbie I was/am).
>
> just still don't understand above sentence. sed -n '/^model
> 1/q;/^model 0/,$p'
The semicolon separates two commands. The first one matches on model 1,
and quits sed (stops processing). The second one is a range command,
matches from the model 0 line to the end of the file ($), and prints
the current line.
Arguably, the single range command (/model 0/,/model 1/) is a better
solution because it also works in the aggregate case (cat *|sed instead
of sed *).
Regards,
Arno
Reply to: