case $location in
ColocationOne)
# Define MOSES LAKE workerarray
server[0]=serverone
server[1]=servertwo
esac
echo ${server[0]}
How do I get this to echo: serverone
?
You set location to the string 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]}"
This script would print serverone.
${server[0]}after my initial edit. The first was a typo. I am just trying to use a variable that I declared inside thecasestatement from outside the case statement.