Skip to content

Instantly share code, notes, and snippets.

@mostlyfine
Created July 31, 2019 15:44
Show Gist options
  • Select an option

  • Save mostlyfine/49a6ab64676b3f39fa94a75bfbb15857 to your computer and use it in GitHub Desktop.

Select an option

Save mostlyfine/49a6ab64676b3f39fa94a75bfbb15857 to your computer and use it in GitHub Desktop.
#/bin/sh
FILENAME=$1
SPLITCMD=csplit
if [ "$(uname)" == 'Darwin' ]; then
SPLITCMD=gcsplit
fi
$SPLITCMD -f table. $1 /^--\ Table\ structure/ {*}
rm table.00
for FILE in `ls table.*`; do NAME=$(sed -n 1p ${FILE} | sed 's/.*`\(.*\)`/\1/'); mv ${FILE} ${NAME}.sql; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment