#!/bin/bash
servers="server1;server2;server3"
IFS=';' read -r -a array <<< "$servers"
rand=$[ $RANDOM % ${#array[@]} ]
echo ${array[$rand]}
Comment déclarer et itérer sur un tableau associatif en bash :
declare -A array
array[foo]=bar
array[bar]=foo
for i in "${!array[@]}"
do
echo "key : $i"
echo "value: ${array[$i]}"
done
ArrayList<DeviceId> reslist = new ArrayList<DeviceId>();
reslist.add....
return reslist.toArray(new DeviceId[reslist.size()]);