Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/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
Add Comment
Please, Sign In to add comment