#!/bin/bash # Extract the file with the proper command based on the filename. # NOTE: If a file extension is not supported, it will be ignored rather than error out. This is by design. #source `which ttPM-funcs` 2>/dev/null || exit 1 ERR_VAL=0 # For each parameter entered extract the file until [ -z "$1" ] do case "$1" in *.tar.gz | *.tgz | *.tar.Z ) tar -xzf "$1" let "ERR_VAL += $?" ;; *.tar.bz2 | *.tbz2 ) tar -xjf "$1" let "ERR_VAL += $?" ;; *.tar | *.TAR ) tar -xf "$1" let "ERR_VAL += $?" ;; *.bz2 ) bunzip2 "$1" let "ERR_VAL += $?" ;; *.gz ) gunzip "$1" let "ERR_VAL += $?" ;; *.zip | *.ZIP | *.xpi ) unzip -qq -o "$1" let "ERR_VAL += $?" ;; *.jar ) jar -xf "$1" let "ERR_VAL += $?" ;; *.rar ) unrar x "$1" let "ERR_VAL += $?" ;; esac shift done exit $ERR_VAL