Linux常用自定义脚本系列(dcompile) - 反编译整个jar文件

 
Name: dcompile
 
Description: Compile a single jar file to java classes.
 
Usage: dcompile <FILE-NANE>
 
Example: dcompile ./*.jar
 
Notes:  Please make sure jad is in the system path.
 
Source Code:
#!/bin/bash    
if [ -z ${1} ]
then
    echo "Missing paramer - jar file path"
    exit
fi
JAR_FILE=${1}
JAR_FILE_NAME=$(basename $JAR_FILE)
JAR_FILE_NAME=${JAR_FILE_NAME%%.jar}
DEST_DIR=${2}
if [ -z $DEST_DIR ]
then
    DEST_DIR=$JAR_FILE_NAME
fi
mkdir -p $DEST_DIR
echo "JAR_FILE: ${JAR_FILE}"
echo "JAR_FILE_NAME: ${JAR_FILE_NAME}"
echo "DEST_DIR: ${DEST_DIR}"

rm -r /tmp/$JAR_FILE_NAME &> /dev/null
unzip $JAR_FILE -d /tmp/$JAR_FILE_NAME
find /tmp/$JAR_FILE_NAME -name "*.class" -exec jad -r -s java -d $DEST_DIR {} \;

你可能感兴趣的:(linux,脚本,自定义,常用,系列)