🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Duda Shell scripting (bash)

#12080
From: J.A. Gutierrez
Date: Mon, 03 Sep 2001 13:00
27 lines
1822 bytes
Artabros <artabros@bigfoot.com> wrote:
:     Hola!!
:        Necesito leer una linea determinada de un fichero de texto con
: un script en bash de dos formas diferentes  :P

:         La primera es leer una linea aleatoria de dicho fichero. Para
: generar dicho nīŋŊ aleatorio uso lo siguiente:

: expr `wc -l prueba|sed s/"[ ]*"//|cut -d" " -f1` \* 32767 / $RANDOM
	
	wc -l < prueba
	y te ahorras el sed y el cut

	word="`tail +$LINE $WORDS | head -1`"
	o awk

:         La segunda forma es leer las lineas del fichero
: consecutivamente.
	
	read


-- 
PGP and other useless info at      \
http://www.cps.unizar.es/~spd/      \
finger://daphne.cps.unizar.es/spd    \       Timeo Danaos et dona ferentes
ftp://ivo.cps.unizar.es/pub/          \                         (Virgilio)   
Technical Details
Message-ID: <9mvusk$aab$1@news.unizar.es>
Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!newsfeeds.belnet.be!news.belnet.be!news-ge.switch.ch!news.rediris.es!news.unizar.es!not-for-mail
References: <f6r2pts6p82l1tpjnfj2dte39hkoh6bjkp@4ax.com>

Show Full Headers
Complete Article Headers
X-Google-Language: SPANISH,ASCII
X-Google-Thread: f86c8,8233a2292fd245b9
X-Google-Attributes: gidf86c8,public
X-Google-ArrivalTime: 2001-09-03 05:44:50 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!newsfeeds.belnet.be!news.belnet.be!news-ge.switch.ch!news.rediris.es!news.unizar.es!not-for-mail
From: "J.A. Gutierrez" <spd@daphne.cps.unizar.es>
Newsgroups: es.comp.os.linux.programacion
Subject: Re: Duda Shell scripting (bash)
Date: 3 Sep 2001 13:00:04 GMT
Organization: Rank
Lines: 27
Message-ID: <9mvusk$aab$1@news.unizar.es>
References: <f6r2pts6p82l1tpjnfj2dte39hkoh6bjkp@4ax.com>
NNTP-Posting-Host: daphne.cps.unizar.es
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
X-Trace: news.unizar.es 999522004 10571 155.210.152.20 (3 Sep 2001 13:00:04 GMT)
X-Complaints-To: usenet@news.unizar.es
NNTP-Posting-Date: 3 Sep 2001 13:00:04 GMT
User-Agent: tin/1.4.5-20010409 ("One More Nightmare") (UNIX) (IRIX/6.2 (IP22))