Skip to content

Instantly share code, notes, and snippets.

@glegoux
Last active August 10, 2017 15:00
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 glegoux/27c2a1fc1e5b2d45edf9ee650aef4439 to your computer and use it in GitHub Desktop.
Save glegoux/27c2a1fc1e5b2d45edf9ee650aef4439 to your computer and use it in GitHub Desktop.
[Bash] Manipulate JAR (Java ARchive) file with extension .jar
#!/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