🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Preguntilla de sed

#7120
From: garlito
Date: Mon, 31 Mar 2003 16:45
28 lines
1834 bytes
sio2 escribi�:

> Es decir, un fichero con distintos textos independientes separados
> por una l�nea que contiene solamente el caracter '%'.
 
> Lo que quiero es crearme un peque�o script (que use sed) , de manera
> que el script admita como par�metro un n�mero que indica el texto que
> quiero rescatar. Por ejemplo:
 
> $ saca.sh 20

He estado mirando, pero con sed no he visto la manera. Te pongo el
script sin sed por si te vale

Un saludo

#!/bin/bash
declare -i n=1
encontrado=no
while read; do
   if [ "$REPLY" = "%" ]; then
      [ $encontrado = si ] && exit
      [ $n = $1 ] && { encontrado=si; continue; }
      n=$n+1
   else
      [ $encontrado = si ] && echo $REPLY
   fi
done< fichero
Technical Details
Message-ID: <et7ml-jd.ln1@garlito06400.uned.es>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!nntp.cs.ubc.ca!nntp-relay.ihug.net!ihug.co.nz!west.cox.net!cox.net!news-xfer.cox.net!mainake.escomposlinux.org!pinsa.escomposlinux.org!garlito06400.uned.es!news
References: <1b5b7a1f.0303310242.b117c5@posting.google.com>

Show Full Headers
Complete Article Headers
X-Google-Language: SPANISH,ASCII
X-Google-Thread: f86c8,d868d3e9f4413baf
X-Google-Attributes: gidf86c8,public
X-Google-ArrivalTime: 2003-03-31 08:45:15 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!nntp.cs.ubc.ca!nntp-relay.ihug.net!ihug.co.nz!west.cox.net!cox.net!news-xfer.cox.net!mainake.escomposlinux.org!pinsa.escomposlinux.org!garlito06400.uned.es!news
From: garlito <sgNOSPAMrimas1@alumno.uned.es>
Newsgroups: es.comp.os.linux.programacion
Subject: Re: Preguntilla de sed
Date: Mon, 31 Mar 2003 18:45:02 +0200
Organization: Ecolnet
Lines: 28
Message-ID: <et7ml-jd.ln1@garlito06400.uned.es>
References: <1b5b7a1f.0303310242.b117c5@posting.google.com>
NNTP-Posting-Host: cliente-217216192018.ubrcoa01.supercable.es
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-15
Content-Transfer-Encoding: 8bit
X-Trace: pinsa.escomposlinux.org 1049129113 6460 217.216.192.18 (31 Mar 2003 16:45:13 GMT)
X-Complaints-To: newsmaster@pinsa.escomposlinux.org
NNTP-Posting-Date: Mon, 31 Mar 2003 16:45:13 +0000 (UTC)
User-Agent: slrn/0.9.7.4 (Linux)