technonick (technonick) wrote in linuxhelp,
technonick
technonick
linuxhelp

Bash script help

I am trying to create a simple script that creates 1000 databases in mysql, then creates 1 table and populates the table with 1 line of data

So here is what I have so far:
---------------------------------------
#!/bin/bash

for x in 1000
do
/usr/bin/mysql -e "CREATE DATABASE test$x" # I'm fudging here hoping someone can help me get my variable into the database name

/usr/bin/mysql test,"$x" < test1 # Again Fudging

/usr/bin/mysql test,"$x" < test2 # Again Fudging

done

-------------------------------------

test1 has this:
-------------------------------------
create table names (
firstname varchar(20) not null,
lastname varchar(20) not null,
streetaddr varchar(20) not null,
zipcode varchar(20) not null );
-------------------------------------
And test2
-------------------------------------
insert into names values ('Subin', 'Bob', 'Apt909, Towers', '341B9');
-------------------------------------

Yes my bash is terrible. But can you help me out?
  • Post a new comment

    Error

    default userpic

    Your IP address will be recorded 

  • 0 comments