title: Comparing command-line parameter to a string
body: <p>Here is my code:</p>
  
  <pre><code>#!/bin/bash
  if [ "$#" -ne 2 ] ; then
          echo "$0: exactly 2 arguments expected"
          exit 3
  fi
  
  if [$1 != "file" -a $1 != 'dir'] ; then
          echo "$0: first argument must be string "file" or "dir""
          exit 1
  elif [-e $2 -a -r $2]; then
          if ["$1" = "file" -a -f $2] ; then
                  echo YES
          elif ["$1" = "dir" -a -d $2] ; then
                  echo YES
          else
                  echo NO
          fi
          exit 0
  else
          echo "$0: $2 is not a readable entry"
          exit 2
  fi
  </code></pre>
  
  <p>If I run <code>./lab4 file filename1</code> it will check if the first parameter is the string "file" or "dir" then if the first parameter is "file" and filename1 is a file, it will print yes. Same thing for dir.</p>
  
  <p>It doesn't recognize <code>$1</code> and <code>$2</code>. The code will output:</p>
  
  <pre><code>./lab04Q2: line 7: [file: command not found
  ./lab04Q2: line 10: [-e: command not found
  </code></pre>
  
  <p>even though I did put 2 parameters when running the program.</p>