sed-devel
[Top][All Lists]
Advanced

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

Re: Should it be mentioned that 0~n syntax accepts 0 address as well?


From: Jim Meyering
Subject: Re: Should it be mentioned that 0~n syntax accepts 0 address as well?
Date: Sat, 15 Feb 2025 21:49:09 -0800

On Sun, Feb 9, 2025 at 7:54 AM Arkadiusz Drabczyk
<arkadiusz@drabczyk.org> wrote:
> In the manual it says how to use ~ to specify an address from the 0th
> line:
>
> > Thus, one would use 1~2 to select the odd-numbered lines and 0~2 for
> > even-numbered lines;
> > (...)
> > $ seq 10 | sed -n '0~4p'
> > 4
> > 8
>
> But later in the manual it says:
>
> > 4.5 Zero Address
> >
> > As a GNU sed extension, 0 address can be used in two cases:
> >
> > 1. In a regex range addresses as 0,/regexp/ (see [Zero Address Regex
> > Range], page 25).
> >
> > 2. With the r command, inserting a file before the first line (see
> > Section 7.9 [Adding a header to multiple files], page 53).
> >
> > Note that these are the only places where the 0 address makes sense;
> > Commands which are given the 0 address in any other way will give an
> > error.
>
> Shouldn't 0~n syntax be mentioned here as well?

Yes. Thanks. I'll push this soon:

Attachment: sed-doc.diff
Description: Binary data


reply via email to

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