Question

I am trying to run .sh file from cygwin on windows 7

My dumdb.sh file content

#!/bin/bash
for database in $(mysql -e "show databases"|awk -F " " '{print $1}') do
    mysqldump -u root -h localhost -p $database > $database.sql
done

On running this command

$ sh dumpdb.sh

m getting following error

bash: line 3: syntax error near unexpected token `mysqldump'
bash: line 3: `mysqldump $database > $database.sql'

Where I am doing wrong?

Was it helpful?

Solution

You are missing a ; before do:

#!/bin/bash
for database in $(mysql -e "show databases"|awk -F " " '{print $1}') ; do
    mysqldump $database > $database.sql
done
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top