rafal1337
rafal1337

Reputation: 184

two variables in one loop - first as a second variable

for i in `seq 1 100` ;
do
    echo manager${i} ansible_host=$$i;
done

$1, $2, $3 etc have value

I want to first execute $i then execute $1 / $2 etc. For example

$i = 5
$5 = 192.168.0.1

finally output which i want to get: manager5 ansible_host=192.168.0.1

Upvotes: 1

Views: 40

Answers (1)

anubhava
anubhava

Reputation: 785186

You can use this loop:

for i in {1..100}; do
    echo "manager$i ansible_host=${!i}"
done

Upvotes: 3

Related Questions