Re: print specific line (by address) within a block of text

Thierry Blanc <[email protected]>
Newsgroups gmane.editors.sed.user
Message-ID <[email protected]>



On 13/12/12 04:25, Brian J. Murrell wrote:
> On 12-12-12 05:14 PM, Davide Brini wrote:
>> Assuming that /d/ *always* starts a block, and omitting some nitpicks
>> that perhaps are unlikely to be important, you could do
>>
>> sed -n '/d/{n;n;p;}'
> Ahh, nice.  What if the offset into the block can be variable, from only
> a few lines to maybe a few dozen lines, so some way to give "n" a number
> of iterations.  I have taken notice of the looping abilities of sed but
> have not come across any way to control loop iteration count with
> numerical values.
>
> Cheers,
> b.


sed -rn '/^d/,/^$/p' your/file | sed -n '3p;'


>
>
>
>
> [Non-text portions of this message have been removed]
>
>
>
> ------------------------------------
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.