title: Bash script to Import Multiple Databses using Loop
body: <p>I have a folder with many DB.sql.gz files, i want to import them all into a new installation of MySQL Server in one go.</p>
  
  <p>I thought using bash script would be a good idea.</p>
  
  <p>So Far, I have this file as an executable.</p>
  
  <pre><code>#!/bin/sh
  for filename in *.gz; 
  do
  tempfile="${z##*/}";
  database_name = "${tempfile%.*}";
  echo database_name;
  mysql -pPASS -u USER;
  CREATE DATABASE database_name;
  unzip z | mysql -pPASS -uUSER database_name;
  done
  </code></pre>
  
  <p>Whats going wrong is that when taking the 'filename' in the for loop, i cant string
  manipulate to to remove the extension, I want to do this because the database files are named as the database. ( just want to remove the .sql.gz to get the db name )</p>
  
  <p>Help appreciated</p>