Created
May 29, 2013 22:54
-
-
Save ejhayes/5674480 to your computer and use it in GitHub Desktop.
Iterates over sql files, imports them into a dummy db, gets information about table structure, prints out 3 sample rows, drops the table.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
for DB_FILE in $(ls *.sql); do | |
echo "Using $DB_FILE" | |
head -c $(expr length "Using $DB_FILE") < /dev/zero | tr '\0' '=' | |
echo | |
mysql erictest2 < $DB_FILE | |
mysql erictest2 --batch --silent -e 'show tables' | xargs -I tbl bash -c "echo Table structure for \'tbl\' && mysql erictest2 -t -e 'desc tbl' && mysql erictest2 -t -e 'select * from tbl limit 3\G; drop table tbl;'" | |
echo | |
done > out.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment