← Back to team overview

sslug-teknik team mailing list archive

Re: shell - variabel = navnet på et andet variabel navn.. hvordan?

 

Takker Emil..

Det ser ud til at det er det jeg skal bruge.. Meen..

CACHE1="fisk/ole"
i=1
TMP=CACHE$i
echo ${!TMP} fisk $!TMP - $!CACHE$i 

alle giver CACHE1 istedet for indholdet af variablen CACHE1..

Har du en ide til hvordan jeg bør anvende den?`inde i {} på en eller
anden måde..

/Klavs

On Wed, 12 Dec 2001 15:56:38 +0100, "Emil S. Hansen"
<esh@xxxxxxxxxxxxx> wrote:

>--n2Pv11Ogg/Ox8ay5
>Content-Type: text/plain; charset=iso-8859-1
>Content-Disposition: inline
>Content-Transfer-Encoding: quoted-printable
>
>On Wed, Dec 12, 2001 at 02:43:36PM +0000, Klavs Klavsen wrote:
>> Har i nogen ideer?
><SNIP man bash>
>       If the first character  of  parameter  is  an  exclamation
>       point,  a  level  of  variable  indirection is introduced.
>       Bash uses the value of the variable formed from  the  rest
>       of parameter as the name of the variable; this variable is
>       then expanded and that value is used in the  rest  of  the
>       substitution,  rather  than the value of parameter itself.
>       This is known as indirect  expansion.   The  exception  to
>       this is the expansion of ${!prefix*} described below.
></SNIP>
>--=20
>Best Regards
>Emil S. Hansen - esh@xxxxxxxxxxxxx - ESH14-DK
>UNIX Administrator, Berlingske Tidende - www.berlingske.dk
>PGP: 109375FA/ABEB 1EFA A764 529E 82B5  0943 AD3B 1FC2 1093 75FA
>
>"I=F8vrigt er det meget rart at slippe for den slags brugere." -
>Mads Bondo Dydensborg om desktopbrugere.
>
>--n2Pv11Ogg/Ox8ay5
>Content-Type: application/pgp-signature
>Content-Disposition: inline
>
>-----BEGIN PGP SIGNATURE-----
>Version: GnuPG v1.0.6 (GNU/Linux)
>Comment: For info see http://www.gnupg.org
>
>iD8DBQE8F3AmrTsfwhCTdfoRAhvcAJ9NX2AUSPEb43B1IidjaNvYw5e02gCg2Klb
>02DWlRtczBjIGZWjDOHLy4I=
>=ucuY
>-----END PGP SIGNATURE-----
>
>--n2Pv11Ogg/Ox8ay5--
>



Follow ups

References