Last active
August 10, 2017 15:00
-
-
Save glegoux/27c2a1fc1e5b2d45edf9ee650aef4439 to your computer and use it in GitHub Desktop.
[Bash] Manipulate JAR (Java ARchive) file with extension .jar
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 | |
usage() { | |
cat << EOF | |
usage: `basename "$0"` jar_name [file_name] | |
See content of archive jar, then content of a file if precised. | |
EOF | |
exit 1 | |
} | |
if [ $# -eq 0 -o $# -gt 2 ]; then | |
usage | |
fi | |
jar_name="$1" | |
file_name="$2" | |
# see file system in a jar file | |
jar tfv "$jar_name" | |
# see content of <file_name> in <jar_name> | |
if [ -n "$file_name" ]; then | |
unzip -p "$jar_name" "$file_name" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment