Hello, I am new to shell scripting so this might be a simple question...also, please excuse me if this is a topic discussed before.
I have declared a bunch of variables as such:
Host_1=32
Host_2=33
Host_3=34
temp=1
numUsers=4
Now, I am trying to go through a loop to access each of these variables. I have established a while loop like so:
while [ $temp -le numUsers]
do
echo "Host 1 = $Host_"$temp""
temp='expr $temp + 1'
done
Now this obviously is incorrect, as it looks for a variable called Host_ and doesn't find it, leaving me with only the value of temp being printed. Is there a way to have it so Host_1 is printed with temp=1? I looked into using an array but I figure there might be a quick solution to this.
I tried your code and it runs fine until ' echo ${arr[tmp]} '
I am using the standard shell script though. Are arrays not supported in it or is there something else I am overlooking? I am getting a bad substitution error by the way.