|
From: | Paolo Bonzini |
Subject: | Re: sed N command with relative addressing |
Date: | Fri, 16 May 2014 09:47:27 +0200 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 |
Il 16/05/2014 07:03, Hiroto Kagotani ha scritto:
$ seq 1 10 | gsed '3,+3N; s/\n/-/' 1 2 3-4 5-6 7-8 9 10 $ seq 1 10 | gsed '3,6N; s/\n/-/' 1 2 3-4 5-6 7 8 9 10 `3,+3N' seems to be treated as `3,7N'. Is there any reason for the 2nd relative address to be relative to the next line of the 1st address only for N command?
Interesting. This is because "+3" is treated as "3 evaluations of the address", for example:
$ seq 1 10 | sed -n '/[24680]/ {; 1,+3 p; }' 2 4 6 $ seq 1 10 | sed -n '/[24680]/ {; 5,+3 p; }' 6 8 10 $ seq 3 10 | sed -n '/[24680]/ {; /4/,+3 p; }' 4 6 8I suspect this bug has been there forever, though I wouldn't be opposed to fixing it.
Paolo
[Prev in Thread] | Current Thread | [Next in Thread] |