title: escaping special characters in bash, case function
body: <p>I am creating a script in bash. This script will do the same as a MySQL database kan do, I already build the functions, SELECT, INSERT, UPDATE, DELETE and I already created a Login menu for it. Now the last thing I need to do is to be able to insert SQL statements on the command line once I run the script.I have already created the function that allows "--help" to be entered on the command line to run the Help function. I've also already created the option to enter the SELECT command on the command line, for example:</p>
  
  <pre><code>./database.sh SELECT name FROM student
  </code></pre>
  
  <p>This will show a complete list of names that are available in the database. But I can't get the below statement to work:</p>
  
  <p>For example:</p>
  
  <pre><code>./database.sh SELECT * FROM student
  </code></pre>
  
  <p>This should show the complete database that is available. It doesn't though, I've alread thought of escaping the * character but that also does not work. So far I've created this below piece of code that the script will run through before it runs any functions.</p>
  
  <pre><code>if [ -z $1 ]; then
      Inlog
  else
      if [ "$1" = "--help" ] ; then
          Help
      else
  
          case "$*" in
              "SELECT naam FROM student")
                  echo "Hieronder is een overzicht van de namen van de studenten die aanwezig zijn in de database."
                  echo "------------------------"
                  cat $naam_dir
                  ;;
              "SELECT nummer FROM student")
                  echo "Hieronder is een overzicht van de studentnummers van de studenten die in de database aanwezig zijn."
                  echo "------------------------"
                  cat $nummer_dir
                  ;;
              "SELECT mail FROM student")
                  echo "Hieronder is een overzicht van de e-mail adressen van de studenten die in de database aanwezig zijn."
                  echo "-----------------------"
                  cat $mail_dir
                  ;;
              "SELECT \*\ FROM student")
                  paste $naam_dir $nummer_dir $mail_dir | expand t-20
              *)
                  exit
                  ;;
          esac
      fi
  fi
  </code></pre>
  
  <p>I was hoping someone could help me escape these characters. A SQL query should also end with ";", so far I also have not been able to acomplish this in bash either... Maybe someone has an idea.</p>