title: Bash: syntax error near unexpected token `else'
body: <p>I'm getting the following error:</p>
  
  <pre><code>./adduser.sh: line 21: syntax error near unexpected token `else'
  ./adduser.sh: line 21: `        else'
  </code></pre>
  
  <p>I have been stuck here for an hour and I just can not figure it out.</p>
  
  <pre><code>#!/bin/bash
  #==========================================================================================================================================
  # Script Name:  adduser.sh
  # By:           Tim mayo
  # Date:         3/2013
  # Purpose:      Add a user to the Linux system
  # Command line: adduser.sh
  #
  #==========================================================================================================================================
          read -p "Enter username : " username
          read -s -p "Enter password : " password
          egrep "^$username" /etc/passwd &gt;/dev/null
          if [ $? -eq 0 ]; then
                  echo "$username exists!"
                  exit 1
          else
                  pass=$(perl -e 'print crypt($ARGV[0], "password")' $password)
                  useradd -m -p $pass $username
                  [ $? -eq 0 ] &amp;&amp; echo "User has been added to system!" || echo "Failed to add a user!"
          fi
                  else
                          echo "Root user can only add a user to the Linux system"
                          exit 2
  fi
  </code></pre>