| 1 | #!/bin/bash |
| 2 | |
| 3 | usage(){ |
| 4 | echo " |
| 5 | Written by Brian Bushnell |
| 6 | Last modified April 25, 2019 |
| 7 | |
| 8 | Description: Compresses or decompresses files based on extensions. |
| 9 | This only exists because the syntax and default behavior of many |
| 10 | compression utilities is unintuitive; it is just a wrapper, and |
| 11 | relies on existing executables in the command line (pigz, lbzip, etc.) |
| 12 | Does not delete the input file. |
| 13 | Does not untar files. |
| 14 | |
| 15 | Usage: unzip.sh in=<file> out=<file> |
| 16 | |
| 17 | Parameters: |
| 18 | in=<file> Input file. |
| 19 | out=<file> Output file for good reads. |
| 20 | zl= Set the compression level; 0-9 or 11. |
| 21 | |
| 22 | Please contact Brian Bushnell at [email protected] if you encounter any problems. |
| 23 | " |
| 24 | } |
| 25 | |
| 26 | #This block allows symlinked shellscripts to correctly set classpath. |
| 27 | pushd . > /dev/null |
| 28 | DIR="${BASH_SOURCE[0]}" |
| 29 | while [ -h "$DIR" ]; do |
| 30 | cd "$(dirname "$DIR")" |
| 31 | DIR="$(readlink "$(basename "$DIR")")" |
| 32 | done |
| 33 | cd "$(dirname "$DIR")" |
| 34 | DIR="$(pwd)/" |
| 35 | popd > /dev/null |
| 36 | |
| 37 | #DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/" |
| 38 | CP="$DIR""current/" |
| 39 | |
| 40 | z="-Xmx80m" |
| 41 | set=0 |
| 42 | |
| 43 | if [ -z "$1" ] || [[ $1 == -h ]] || [[ $1 == --help ]]; then |
| 44 | usage |
| 45 | exit |
| 46 | fi |
| 47 | |
| 48 | calcXmx () { |
| 49 | source "$DIR""/calcmem.sh" |
| 50 | setEnvironment |
| 51 | parseXmx "$@" |
| 52 | } |
| 53 | calcXmx "$@" |
| 54 | |
| 55 | unzip() { |
| 56 | local CMD="java $EA $EOOM $z -cp $CP jgi.Unzip $@" |
| 57 | # echo $CMD >&2 |
| 58 | eval $CMD |
| 59 | } |
| 60 | |
| 61 | unzip "$@" |