Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to assign a batch of variables

Status
Not open for further replies.

huangwason

Programmer
Oct 10, 2006
21
DE
I am trying to assign such as a1=1, a2=2, ... , a8=8, and I wrote a script such like

for (( b=1; b <= 8 ; b++ ))
do
a$b=$b
echo $(a$b)
done

the output as
./for-loop.sh: line 6: A1=1: command not found
./for-loop.sh: line 7: a1: command not found

what is the problem?
 
Can you deal with an array a[$b], instead of several a1, a2, etc... variables?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top