I am trying to utilize an API. I need to either do some type of for loop  that replaces or utilizes 2 variables...In pseudo..# Declare New Serversnewserver=(box001box002box003box004box005)# Declare hostnamesnewhostname=(box001.domain.combox002.domain.combox003.domain.combox004.domain.combox005.domain.com)I need to replace NEWSERVER and NEWHOSTNAME inhttp://server/api/duplicateobject.htm?id=2928&name=NEWSERVER&host=NEWHOSTNAME&targetid=3120so that it looks like thishttp://server/api/duplicateobject.htm?id=2928&name=box001&host=box001.zcloud.com&targetid=3120I just need it to loop through all of hosts listed.
Loop with 2 variables in a bash script
bash;scripting;array
The criteria isnt defined that well, but this is how I would do it:hosts=(box001:box001.domain.combox002:box002.domain.combox003:box003.domain.combox004:box004.domain.combox005:box005.domain.com)uri=http://server/api/duplicateobject.htm?id=2928&name=NEWSERVER&host=NEWHOSTNAME&targetid=3120for host in ${hosts[@]}; do    IFS=: names=( $host )    hosturi=${uri/NEWSERVER/${names[0]}}    hosturi=${hosturi/NEWHOSTNAME/${names[1]}}    echo $hosturidoneOutputs:http://server/api/duplicateobject.htm?id=2928&name=box001&host=box001.domain.com&targetid=3120http://server/api/duplicateobject.htm?id=2928&name=box002&host=box002.domain.com&targetid=3120http://server/api/duplicateobject.htm?id=2928&name=box003&host=box003.domain.com&targetid=3120http://server/api/duplicateobject.htm?id=2928&name=box004&host=box004.domain.com&targetid=3120http://server/api/duplicateobject.htm?id=2928&name=box005&host=box005.domain.com&targetid=3120Advantages:Keeps it clear which server name corresponds with which fqdn.Its pure bash & uses no external anything..If the server name is always going to be the first part of the fqdn, the array can be even simpler and you can have bash figure the server name out from the fqdn.