0

I had to try to make a code to automate steamcmd but it always gives me the following error:

syntax error near unexpected token 'fi'

Code:

STEAMCMDDOWN="https://steamcdn-a.akamihd.net/client/installer/steamcmd_linux.tar.gz"

STEAMDIR="~/steamcmd"

if [! -d "$STEAMDIR" ]; then
  mkdir "~/steamcmd"
  cd "~/steamcmd"
else
  if [! -f "steamcmd.sh" ]; then
    wget "$STEAMCMDDOWN" 
    tar +xf "steamcmd_linux.tar.gz"
  else
    echo "steamcmd installed" 
  fi 
  exit
fi

Can someone please explain why I'm getting this error?

Jonny Henly
  • 4,023
  • 4
  • 26
  • 43
Rube200
  • 1
  • 1
  • 2
  • To get ahead of your next question, don't quote the `~`; there is no literal directory named `~`, and the tilde won't expand if it is quoted. `STEAMDIR=~/steamcmd`. Same goes for the code that creates the directory. – chepner Jul 15 '16 at 15:20

1 Answers1

1

[ is a command (synonym for test), so you need to have some space after it:

if [ ! -d "$STEAMDIR" ]; then ...
Eugene Yarmash
  • 142,882
  • 41
  • 325
  • 378