bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

sed N command with relative addressing


From: Hiroto Kagotani
Subject: sed N command with relative addressing
Date: Fri, 16 May 2014 14:03:49 +0900

Hello,

I am using sed (gsed) on FreeBSD:
--------
$ gsed --version
gsed (GNU sed) 4.2.2
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Jay Fenlason, Tom Lord, Ken Pizzini,
and Paolo Bonzini.
GNU sed home page: <http://www.gnu.org/software/sed/>.
General help using GNU software: <http://www.gnu.org/gethelp/>.
E-mail bug reports to: <address@hidden>.
Be sure to include the word ``sed'' somewhere in the ``Subject:'' field.
--------

Recently, I needed to use N command and found a weird behavior.

I expect that range specification using relative address like `3,+3' is
treated as `3,6' in absolute addressing.  For example, the following two
commands produce the same result:

$ seq 1 10 | gsed '3,+3s/$/!/'
$ seq 1 10 | gsed '3,6s/$/!/'

However, they are different for N command:

$ 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?

Thank you very much.

Best Regards,

-- 
Hiroto Kagotani
<address@hidden>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]