Bash Script - check argument in array
#create an array
arr=(1 2 3 4 5 6)
#declare variable "rn" and random select a nuber
declare -i rn=$RANDOM*${#arr[@]}/32767echo "
rn = $rn"
#print all arguments in array
echo "array : ${arr[@]}"
#check if rn in array
for i in ${arr[@]}
do
if [ "$i" = "$rn" ]; then
echo "HI!!"
fi
done
echo "==ending=="