Created
June 21, 2012 13:01
-
-
Save skinofstars/2965626 to your computer and use it in GitHub Desktop.
Update all MySQL ENGINE TYPE .sql within a collection of Zips. For updating legacy update files.
This file contains 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
#!/usr/bin/env bash | |
# for each zip in the folder | |
# unpack to temp loc | |
# for each sql | |
# find "TYPE=" and replace with "ENGINE=" | |
# repack and replace original | |
# remove temp loc | |
FILES=$1 | |
find $FILES -name "*.zip" | while read ZIP; | |
do | |
echo $ZIP | |
# extract | |
unzip -oq $ZIP -d $ZIP-tmp | |
# for each file ending in .sql | |
find $ZIP-tmp -name "*.sql" | while read SQLFILE; | |
do | |
# recursive sed search and replace | |
sed -i 's/TYPE=/ENGINE=/g' $SQLFILE | |
done | |
# repack | |
# zip will replace/update a file with new contents, however... | |
# wat - gotta go in to folder or it just adds to zip as sub dir | |
cd $ZIP-tmp | |
for wat in `ls`;do | |
zip -rq ../$ZIP $wat | |
done | |
cd ../ | |
# tidy | |
rm -rf $ZIP-tmp | |
done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is brittle, aggressive and destructive. Don't just go running it unless you know what you're doing!!!