Reputation: 2979
Here is my one-liner:
sed -n '/BEGIN/,/END/{$d;1d;p}' query
And query:
trash BEGIN first labas END nieko nėra BEGIN second iki END nesimato
I expect this result:
labas iki
However, I get this:
BEGIN first labas END BEGIN second iki END
What do I misunderstand about sed context? Shouldn't {$d,1d;p}
delete first and last line of the matching input?
Upvotes: 0
Views: 508
Reputation: 58371
This might work for you:
sed -n '/BEGIN/,/END/{//!p}' file
labas
iki
Upvotes: 1
Reputation: 99094
No, it deletes any line of the matching input that is the first or last line of the file. You can see the effect if you remove the first two lines of query
(so that the first line is "BEGIN").
Upvotes: 1