Skip to content

Instantly share code, notes, and snippets.

@rubenerd
Created March 17, 2016 05:42
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rubenerd/928fbfc87d36ba829297 to your computer and use it in GitHub Desktop.
Save rubenerd/928fbfc87d36ba829297 to your computer and use it in GitHub Desktop.
Recompress zip to tar.xz
#!/bin/sh
######
## Recompresses ZIP files to tar.xz
## - Extracts to temp folder to prevent tarbombs
## - Recontainerises as tar
set -e
set -x
_source=`echo $1 | sed "s/\.zip\$//"`;
mkdir "$_source"
unzip -d "./$_source/" "$1"
tar -cvf "${_source}.tar" "./$_source/"
xz -9vv "${_source}.tar"
rm -rf "./$_source/"
rm -rf "$1"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment