Skip to content

Instantly share code, notes, and snippets.

@complex857
Created February 29, 2012 21:14
Show Gist options
  • Save complex857/1944412 to your computer and use it in GitHub Desktop.
Save complex857/1944412 to your computer and use it in GitHub Desktop.
extract specific db from mysqldump output
#!/bin/bash
# copypasted from the internet, added foreign key check disable/enable
line=`grep -m 1 -n "Current Database: .$2" $1 | cut -d ":" -f 1`
next=`sed 1,${line}d $1|grep -m 1 -n "Current Database" | cut -d ":" -f 1`
end=$(($line + $next -1))
echo set foreign_key_checks = 0';'
sed -n ${line},${end}p $1
echo set foreign_key_checks = 1';'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment