case $location in
ColocationOne)
# Define MOSES LAKE workerarray
server[0]=serverone
server[1]=servertwo
esac
echo ${server[0]}
我如何让它回显:serverone
?
答案1
您设置location
为字符串ColocationOne
:
#!/bin/bash
location=ColocationOne
case $location in
ColocationOne)
# Define MOSES LAKE workerarray
server[0]=serverone
server[1]=servertwo
# or: server=( serverone servertwo )
esac
echo "${server[0]}"
该脚本将打印serverone
.