Link to home
Start Free TrialLog in
Avatar of huxun
huxun

asked on

bash-script: variable variable

Hi!
 I'm trying to get this:

---------------------------
#!/bin/bash

i1="193 4 0 0 16"
i2="194 144 0 0 16"

count=2
cur=0

n=0
while [ $n -ln $count ]; do
  let n=n+1
  cur=i$n
  echo $[$cur]
done
-----------------------------

to echo this:

-----------------------------
193 4 0 0 16
194 144 0 0 16
-----------------------------

but I only get this error:
193 4 0 0 16: syntax error in expression (error token is "4 0 0 16")
and then it terminates. Any ideas how to make this work?
Avatar of jolbe13
jolbe13

I usually solve this kind of problem with arrays. If you are not familiar with arrays I can write you an example.
ASKER CERTIFIED SOLUTION
Avatar of jolbe13
jolbe13

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of huxun

ASKER

Yeah ... I thought of an array, but didn't think bash would support them.

Well, I was wrong :|

Thanks!