Skip to content

Instantly share code, notes, and snippets.

@h2000
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save h2000/9160411 to your computer and use it in GitHub Desktop.
Save h2000/9160411 to your computer and use it in GitHub Desktop.
bash script to merge two jars (e.g. for minecraft, commandline)
$ 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