Missing bracket operator [ (test). It should be something like this:
if [ "$server" = "Creative+Survival" ] then echo "true" else echo "false" fi
NOTE. The spaces around these brackets are important. The square brackets around the conditional test are actually synonymous with the test statement. So the above is equivalent to:
if test "$server" = "Creative+Survival" then echo "true" else echo "false" fi
But everyone uses brackets; I rarely see a script that uses the keyword test .
Also allowed in the bash shell (although this is not so portable because it is not a POSIX standard) is to use double brackets:
if [[ "$server" = "Creative+Survival" ]] then
Here's a link to a page describing the differences between [ , [[ and test : http://mywiki.wooledge.org/BashFAQ/031
Update
Q: It seems to work, but it spits out an error code if I choose something other than "Creative + Survival". Is this supposed to happen?
A: It is not clear which error code spat out which component. I expect you to want to check every possible choice. You can do this with elif or with case .
if [ "$server" = "Creative+Survival" ] then echo "Creative and Survival" elif [ "$server" = "Tekkit Cheat Survival" ] then echo "Tekkit Cheat Survival" elif [ "$server" = "Flat Tekkit" ] then echo "Flat Tekkit" else ehco "no action for specified server" fi case "$server" in 'Creative+Survival') echo "Creative and Survival" ;; 'Tekkit Cheat Survival') echo "Tekkit Cheat Survival" ;; *) echo "no action found for server $server" ;; esac
(NOTE: Indentation is for readability only; bash takes care of newlines, not leading spaces.)
source share