Last active
October 27, 2023 21:44
-
-
Save natemcmaster/5e36e3953c586e4b407a7bb9316b8772 to your computer and use it in GitHub Desktop.
Convert zip to tar.gz file
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 | |
if [[ $# < 2 ]]; then | |
echo "Usage: [src] [dest]" | |
exit 1 | |
fi | |
function realpath() { | |
[[ $1 = /* ]] && echo "$1" || echo "$PWD/${1#./}" | |
} | |
src="$(realpath $1)" | |
dest="$(realpath $2)" | |
echo "Converting:" | |
echo " - $src" | |
echo " => $dest" | |
tmp="$(mktemp -d)" | |
echo "Using temp dir $tmp" | |
function cleanup() { | |
echo "Cleaning up" | |
rm -rf $tmp | |
echo "Done" | |
} | |
trap cleanup INT TERM EXIT | |
set -e | |
unzip -q $src -d $tmp | |
chmod -R +r $tmp | |
tar -c -z -f $dest -C $tmp . |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment