🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: es.comp.os.linux.programacion
Article #13341

Re: Sustituir una sola vez con sed (o perl)

#13341
From: Pere Pujal Carabantes
Date: Tue, 06 Mar 2001 20:13
52 lines
2476 bytes
El 06 Mar 2001 15:44:07 +0100,en Han Solo va escriure 
en es.comp.os.linux.programacion:
>
>Hola a todos.
>
Hola
 
>Tengo una duda con sed. �como se hace para que sustituya un texto *una
>sola vez* en un fichero le�do de la antrada est�ndar?. La idea, es
>
>
>%----------------
>%%Page: 0 0
>showpage
>%----------------
>%%Page:
>
>El problema es que la cadena %%Page: aparece en cada salto de p�gina,
>y esto se trata s�lo de ponerlo en el primer salto, para que meta una
>p�gina en blanco. 
>
>He conseguido que lo sustituya, pero la sutituci�n la hace en todas
>las p�ginas. Lo que quiero es que lo haga una sola vez. 
>
>Por cierto, la p�gina man de sed sux :-)

Las he visto mejores pero...

Addresses
       Sed commands can be given with no addresses, in which case
       the command will be executed for all input lines; with one
       address, in which case the command will only  be  executed
       for  input  lines  which  match  that address; or with two
       addresses, in which case the command will be executed  for
       all  input  lines which match the inclusive range of lines
       starting from the first address and continuing to the sec�
       ond  address.   Three things to note about address ranges:
       the syntax is addr1,addr2 (i.e., the addresses  are  sepa�
       rated  by  a  comma);  

Prueba con esto en un fichero

1,3{
s/cadena a substituir/cadena nueva/
}

y con sed -f nombre_del_fichero nombre_del_ps
>Un Saludo
>
Saludos

Pere
Technical Details
Message-ID: <slrn9aah86.ta.pere@hola.fou.net>
Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-03!supernews.com!cyclone-sf.pbi.net!63.208.208.143!feed2.onemain.com!feed1.onemain.com!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!npeer.kpnqwest.net!news!pere
References: <8766hn6jpk.fsf@alderaan.maptel.es>

Show Full Headers
Complete Article Headers
X-Google-Language: SPANISH,ASCII
X-Google-Thread: f86c8,57bf867c8699b7fc
X-Google-Attributes: gidf86c8,public
X-Google-ArrivalTime: 2001-03-06 11:18:07 PST
From: pere@hola.fou.net (Pere Pujal Carabantes)
Newsgroups: es.comp.os.linux.programacion
Subject: Re: Sustituir una sola vez con sed (o perl)
References: <8766hn6jpk.fsf@alderaan.maptel.es>
Message-ID: <slrn9aah86.ta.pere@hola.fou.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-15
Content-Transfer-Encoding: 8bit
User-Agent: slrn/0.9.6.2 (Linux)
Date: Tue, 6 Mar 2001 21:13:58 +0100
NNTP-Posting-Host: 212.166.154.222
X-Original-NNTP-Posting-Host: 212.166.154.222
X-Trace: 6 Mar 2001 20:16:41 +0100, 212.166.154.222
Lines: 52
Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-03!supernews.com!cyclone-sf.pbi.net!63.208.208.143!feed2.onemain.com!feed1.onemain.com!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!npeer.kpnqwest.net!news!pere