Skip to content


Validar si dos JARs tienen el mismo contenido

Simple, con un script de shell... lamentablemente cmp jar1.jar jar2.jar no funciona.


#!/bin/bash
if [ $# != 2 ] ; then
echo "Debe proporcionar dos jars como argumentos"
exit 2
fi
TMP1=/tmp/j1-$RANDOM
TMP2=/tmp/j2-$RANDOM
mkdir $TMP1
mkdir $TMP2
cp $1 $TMP1/j1.jar
cp $2 $TMP2/j2.jar
cd $TMP1
jar xf j1.jar
cd $TMP2
jar xf j2.jar
rm -f $TMP1/j1.jar $TMP2/j2.jar
if diff -r $TMP1 $TMP2
then
echo "Contenidos iguales"
fi
rm -rf $TMP1 $TMP2

Share

Posted in Java.