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 | |
if [[ "-" == "-$1" ]] | |
then | |
echo Please specify file name | |
exit 1 | |
fi | |
for i in "$@" | |
do | |
if [[ -f "$i" ]] | |
then | |
case "$i" in | |
*.tar.bz2 | *.tbz2 | *.tbz) | |
pbzip2 -v -d -c -- "$i" | tar xvf - | |
;; | |
*.tar.gz | *.tgz) | |
pigz -v -d -c -- "$i" | tar xvf - | |
;; | |
*.tar.xz | *.txz) | |
pixz -d "$i" /dev/stdout | tar xvf - | |
;; | |
*.tar.lrz | *.tlrz) | |
lrzip -vv -f -o - -d "$i" | tar xvf - | |
;; | |
*.tar.7z | *.t7z) | |
7z x -so "$i" | tar xvf - | |
;; | |
*.bz2) | |
pbzip2 -v -d -- "$i" | |
;; | |
*.rar) | |
unrar x "$i" | |
;; | |
*.gz) | |
pigz -v -d -- "$i" | |
;; | |
*.xz) | |
pixz -d "$i" "$(basename "$i" .xz)" | |
;; | |
*.lrz) | |
lrzip -vv -d "$i" | |
;; | |
*.tar) | |
tar xvf "$i" | |
;; | |
*.zip) | |
unzip "$i" | |
;; | |
*.Z) | |
uncompress "$i" | |
;; | |
*.7z) | |
7z x "$i" | |
;; | |
*) | |
echo "$i cannot be extracted via $(basename $0)" | |
;; | |
esac | |
else | |
echo "$i is not a valid file" | |
fi | |
done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment