Q:

Redirect mysqldump to a file from a bash script

From the command line I can do a dump and redirect it to a file without any issue.
sql=mysql_dump.sql
run_sql="mysqldump -u root -p scope_import > $sql"
$run_sql

When I run it from this script it gives an error: Not such table '>' so its no seeing the > as a redirect rather a table name.

A:

How about simply:
sql=mysql_dump.sql
mysqldump -u root -p scope_import > $sql

(I hope I haven't misunderstood your question).

