🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: bash: ambito de variables con while

#9160
From: Lepton
Date: Thu, 29 Aug 2002 16:44
27 lines
1640 bytes
On Thu, 29 Aug 2002, jG-PPz wrote:

# Hola.
# Estamos desarrolando un script para automatización de estadisticas
# de news, y me ha surgido un grave problema:
#
# Por qué el ambito de una variable en bash dentro de un while se
# acaba al salir de éste?

No estoy seguro, pero diria que las variables que usa
el do..while son locales.

Puedes resolverlo usando una variable "compan~era", o sea:

while read variable
do
	other=$variable
	echo "$variable"
done

echo $other

Supongo que lo que quieres es eso, quedarte con el ultimo
valor.. si no es asi, explicalo mejor :)

Lepton.
Technical Details
Message-ID: <Pine.LNX.4.44.0208291842350.14234-100000@lorien.local>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!opentransit.net!fu-berlin.de!uni-berlin.de!c-134-120-84.d.dial.de.ignite.NET!not-for-mail
References: <lnclka.5q3.ln@192.168.0.102>

Show Full Headers
Complete Article Headers
X-Google-Language: SPANISH,ASCII
X-Google-Thread: f86c8,b26f7a7eb5428370
X-Google-Attributes: gidf86c8,public
X-Google-ArrivalTime: 2002-08-29 23:06:02 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!opentransit.net!fu-berlin.de!uni-berlin.de!c-134-120-84.d.dial.de.ignite.NET!not-for-mail
From: Lepton <reinob@jazzfree.com>
Newsgroups: es.comp.os.linux.programacion
Subject: Re: bash: ambito de variables con while
Date: Thu, 29 Aug 2002 18:44:23 +0200
Lines: 29
Message-ID: <Pine.LNX.4.44.0208291842350.14234-100000@lorien.local>
References: <lnclka.5q3.ln@192.168.0.102>
NNTP-Posting-Host: c-134-120-84.d.dial.de.ignite.net (62.134.120.84)
Mime-Version: 1.0
Content-Type: TEXT/PLAIN; charset=X-UNKNOWN
Content-Transfer-Encoding: QUOTED-PRINTABLE
X-Trace: fu-berlin.de 1030687561 53766549 62.134.120.84 (16 [130846])
X-Orig-Path: localhost!reinob
In-Reply-To: <lnclka.5q3.ln@192.168.0.102>