Re: sed N command with relative addressing

Hiroto Kagotani <[email protected]>
Newsgroups gmane.comp.gnu.utils.bugs
Message-ID <CAC_W2odSqR_3ykamV_W9jhnx4GZr418enHj_x-6wXMbPLBvwYA@mail.gmail.com>
Hi, thank you for reply.

2014-05-16 16:47 GMT+09:00 Paolo Bonzini <[email protected]>:
> $ seq 1 10 | sed -n '/[24680]/ {; 1,+3 p; }'
> $ seq 1 10 | sed -n '/[24680]/ {; 5,+3 p; }'
> $ seq 3 10 | sed -n '/[24680]/ {; /4/,+3 p; }'

Wow, they are more confusing.  I think no one can tell
why the followings are so different.

$ seq 1 10 | sed -n '/[1256789]/ {; 1,+3p; }'
1
2
5

$ seq 1 10 | sed -n '/[1256789]/ {; 2,+3p; }'
2
5

$ seq 1 10 | sed -n '/[1256789]/ {; 3,+3p; }'
5
6
7
8

I wish sed behavior is more intuitively predictable.

Regards,

-- 
Hiroto Kagotani
<[email protected]>
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.