I have array:
declare -A server
server[172.16.170.1]='t1.com'
server[172.16.170.2]='t2.com'
server[172.16.170.3]='t3.com'
server[172.16.170.4]='t4.com'
server[172.16.170.5]='t5.com'
.....
I don't want to write every time, "t1,com,t2.com ..." I want to increment it Ok:
first=0
first=$(($first+1))
It is work for the first element.
first=0
first=$(($first+1))
declare -A server
server[172.16.170.1]='t$first.com'
server[172.16.170.2]='t$first.com'
server[172.16.170.3]='t$first.com'
server[172.16.170.4]='t$first.com'
server[172.16.170.5]='t$first.com'
.....
In output we will have:
server[172.16.170.1]=t1.com
server[172.16.170.2]=t1.com
server[172.16.170.3]=t1.com
server[172.16.170.4]=t1.com
server[172.16.170.5]=t1.com
.....
I know, that we should use loop, but if i have a lot of servers, how i should use loop "for" ? With all my array variables ?