[uylug-programming] Una de variables del BASH

Haroldo Stenger haroldo.stenger at gmail.com
Fri Oct 5 14:56:54 PDT 2012


hola Andrés,

[haroldo at anacoluto ~]$ hola=chau
[haroldo at anacoluto ~]$ chau=taluego
[haroldo at anacoluto ~]$ echo ${!hola}
taluego

mirate:
http://tldp.org/LDP/abs/html/ivr.html

y esta críptica man bash parte:

       ${!prefix*}
       ${!prefix@}

              Names  matching  prefix.  Expands to the names of variables
whose names begin with prefix, separated by the first character of the IFS
spe‐
              cial variable.  When @ is used and the expansion appears
within double quotes, each variable name expands to a separate word.

       ${!name[@]}
       ${!name[*]}
              List of array keys.  If name is an array variable, expands to
the list of array indices (keys) assigned in name.  If name is not an
 array,
              expands to 0 if name is set and null otherwise.  When @ is
used and the expansion appears within double quotes, each key expands to a
sepa‐
              rate word.

saludos
Haroldo

El 5 de octubre de 2012 17:18, Andres Tarallo <atarallo at acm.org> escribió:

> Ya lo probe, quise hacer algo como ${$idx}, pues me interesa ir
> procesando una por una cada variable y sus contenidos. Directamente no
> me corre el shellscript.
>
> Y buscando en google no encontre nada, estoy un poco perdido de que buscar.
>
> El día 5 de octubre de 2012 17:14, Carlos M. Martinez
> <carlosmarcelomartinez at gmail.com> escribió:
> > Creo que precisas algo asi como una doble interpolación, algo como
> > ${$lista}, pero te cuento que las veces que lo trate de usar no me
> > funciono muy bien.
> >
> > s2
> >
> > C.
> >
> >
> > On 10/5/12 5:09 PM, Andres Tarallo wrote:
> >> La tiro aca, es mas de programacion que de otra cosa.
> >>
> >> Tengo definidas en un script variables
> >>
> >> var1=" uno dos tres cuatro"
> >> var2="5 5 6 7 89 90 90·"
> >> .
> >> .
> >> .
> >> varn=" awqw wewew rt6rtr  yuyuy ioioi"
> >>
> >> Luego tengo una variable que llame lista, con los nombres de  las n
> >> variables que defini antes:
> >>
> >> lista="var1 var2 var4    ..... varn"
> >>
> >> Lo que quiero hacer es iterar sobre la variable lista, y poder
> >> referirme a los contenidos de las variables.
> >>
> >> quiero hacer algo como:
> >>
> >> for idx in $lista; do
> >>         # aca accedo al contenido  cada una de las variables del listado
> >> done
> >>
> >> Escucho ideas
> >>
> >> Andrès
> >> _______________________________________________
> >> Uylug-programming mailing list
> >> Uylug-programming at listas.uylug.org.uy
> >> http://listas.uylug.org.uy/listinfo.cgi/uylug-programming-uylug.org.uy
> >
> _______________________________________________
> Uylug-programming mailing list
> Uylug-programming at listas.uylug.org.uy
> http://listas.uylug.org.uy/listinfo.cgi/uylug-programming-uylug.org.uy
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.uylug.org.uy/pipermail/uylug-programming-uylug.org.uy/attachments/20121005/d96142a1/attachment-0002.htm>


More information about the Uylug-programming mailing list