Last active
August 29, 2015 13:56
-
-
Save h2000/9160411 to your computer and use it in GitHub Desktop.
bash script to merge two jars (e.g. for minecraft, commandline)
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
$ cat ~/merge.sh | |
#!/bin/bash | |
function die { | |
echo $1 | |
exit -1 | |
} | |
[[ $# -eq 2 ]] || die "$0 jar1 jar2" | |
JAR1="$1" | |
JAR2="$2" | |
NOW=$(date +"%Y%m%d-%H%M%S") | |
TMP=$(mktemp -d tmp.XXXXXXXXXX) | |
[[ -f $JAR1 ]] || die "jar1 $JAR1 not exists" | |
[[ -f $JAR2 ]] || die "jar2 $JAR2 not exists" | |
echo backup of $JAR1 is $JAR1-saved-$NOW | |
cp -v $JAR1 $JAR1.saved-$NOW | |
echo creating $TMP | |
rm -rf $TMP | |
mkdir -p $TMP | |
echo extracting $JAR1 and $JAR2 into $TMP | |
cd $TMP | |
jar xf ../$JAR1 | |
jar xf ../$JAR2 | |
jar uf ../$JAR1 ./ | |
cd .. | |
echo cleaning up $TMP | |
rm -rf $TMP |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment