title: If statement in shell
body: <p>I'm making a script that executes a file a certain amount of times, then if the file executes properly, it generates another file, and this last file I need to store it in a directory. Example: I execute it like this: ./shell 5 DIR
  Then, the crpit shell executes another file called simulation 5 times and it creates a directory and an output file for each time the file simulation was executed correctly.
  The thing is, I have to put an if statement for the parameters they send when they execute the file, and I don't know how to, here's the code I have:</p>
  
  <pre><code>#!/bin/bash
  
  if [ $# == 3 || $# == 2 ]; then
      c=0
      i=0
      e=0
      cont=0
      while [ $c -le $0 ]
      do
              ./simula cont RES
          e = $?
          if[ e == 0 ]; then
              if[ $# == 3 ]; then
                  chmod RES $2
              mkdir $1$c
              mv RES $1$c/.
              (( c++ ))
          else
              (( i++ ))
          (( cont++ ))
      done
      echo Shan generat $c simulacions correctes.
      echo Hi ha hagut $i simulacions erronies.        
  else 
      echo Nombre de parametres incorrecte: $#.
  fi
  </code></pre>
  
  <p>So I must have either 2 or 3 paremeters when executing the file called shell, and thats why i have that if in the second line of code, however it keeps giving me an error:</p>
  
  <pre><code>./shell: line 12: syntax error near unexpected token `then'
  ./shell: line 12: `             if[ e == 0 ]; then'
  </code></pre>
  
  <p>I'm new to scripts and I have no idea what am I doing wrong, any clues?</p>