Group: linux.debian.user.french
From: fra-duf-no-spam@tourde.org (=?utf-8?Q?Fran=C3=A7ois?= TOURDE)
Date: Sunday, February 24, 2008 5:20 PM
Subject: Re: Substitution par 'sed' une seule fois dans un fichier...

Le 13933i=C3=A8me jour apr=C3=A8s Epoch,
Jacques L'helgoualc'h =C3=A9crivait:

> Fran=C3=A7ois TOURDE a =C3=A9crit, dimanche 24 f=C3=A9vrier 2008, =C3=A0 =
23:32 :
>> Le 13933i=C3=A8me jour apr=C3=A8s Epoch,
>> Sylvain Sauvage =C3=A9crivait:
>>=20
>> > Sylvain Sauvage, dimanche 24 f=C3=A9vrier 2008, 18:37:49 CET
>> >>[???]=20
>> >> M???enfin, bon, il y a s=C3=BBrement d???autres solutions???
>> >
>> > Ben oui, il y a plus simple=C2=A0: 0,/xxx/s//yyy/
>> >
>> > 0,/xxx/=C2=A0: la commande ne s???applique que de la 1re ligne =C3=A0 =
celle qui
>> > correspond =C3=A0 /xxx/
>>=20
>> Je crois qu'il vaut mieux traduire =C3=A7a par: "entre la ligne 1 et la
>> premi=C3=A8re contenant xxx", non?
>
> Non, c'est bien de la ligne 1 =C3=A0 la ligne de la /regexp/, incluses (c=
'est
> peut-=C3=AAtre la m=C3=AAme) ; le truc de la ligne 0 est une extension GN=
U.

En relisant, je me suis rendu compte que ce que j'avais lu la premi=C3=A8re
fois de son explication n'avait rien =C3=A0 voir. J'avais lu: "La commande
ne s'applique qu'=C3=A0 la premi=C3=A8re ligne contenant xxx"... Bref, j'=
=C3=A9tais
dans le gaz encore :) Ou alors c'est le M=C3=A9doc...

> The empty regular expression `//' repeats the last regular
> expression match (the same holds if the empty regular expression is
> passed to the `s' command). Note that modifiers to regular
> expressions are evaluated when the regular expression is compiled,
> thus it is invalid to specify them together with the empty regular
> expression.
> [...]
> GNU `sed' also supports some special two-address forms; all these
> are GNU extensions:
> `0,/REGEXP/'
> A line number of `0' can be used in an address specification like
> `0,/REGEXP/' so that `sed' will try to match REGEXP in the first
> input line too. In other words, `0,/REGEXP/' is similar to
> `1,/REGEXP/', except that if ADDR2 matches the very first line of
> input the `0,/REGEXP/' form will consider it to end the range,
> whereas the `1,/REGEXP/' form will match the beginning of its
> range and hence make the range span up to the _second_ occurrence
> of the regular expression.
>
> Note that this is the only place where the `0' address makes
> sense; there is no 0-th line and commands which are given the `0'
> address in any other way will give an error.

Merci pour ces explications d=C3=A9taill=C3=A9es. Mais ne doit-on pas consi=
d=C3=A9rer
que 1,/xxx/ qui matche la seconde occurence n'est pas plut=C3=B4t un bug?
Dans ce cas, que devrait faire /xxx/,/xxx/ ?

D'autre part, je viens de faire le test sur ma machine, que addr1 soit
0 ou 1, le match marche sur la premi=C3=A8re ligne.

Ok, je sais, je coupe les cheveux en sqrt(2), mais bon...