Guest User

Untitled

a guest
Oct 22nd, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. #!/usr/bin/env bash
  2.  
  3. # for each zip in the folder
  4. # unpack to temp loc
  5. # for each sql
  6. # find "TYPE=" and replace with "ENGINE="
  7. # repack and replace original
  8. # remove temp loc
  9.  
  10. FILES=$1
  11.  
  12. find $FILES -name "*.zip" | while read ZIP;
  13. do
  14. echo $ZIP
  15.  
  16. # extract
  17. unzip -oq $ZIP -d $ZIP-tmp
  18.  
  19. # for each file ending in .sql
  20. find $ZIP-tmp -name "*.sql" | while read SQLFILE;
  21. do
  22. # recursive sed search and replace
  23. sed -i 's/TYPE=/ENGINE=/g' $SQLFILE
  24. done
  25.  
  26. # repack
  27. # zip will replace/update a file with new contents, however...
  28. # wat - gotta go in to folder or it just adds to zip as sub dir
  29. cd $ZIP-tmp
  30. for wat in `ls`;do
  31. zip -rq ../$ZIP $wat
  32. done
  33. cd ../
  34.  
  35. # tidy
  36. rm -rf $ZIP-tmp
  37.  
  38. done
Add Comment
Please, Sign In to add comment