Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- extract () {
- [ ! "$1" ] && { echo "usage: extract [file]"; return 0; }
- [ ! -f "$1" ] && { echo "$1 is not a file!"; return 1; }
- case "$1" in
- *.tar.bz2) tar xvjf "$1" || return $? ;;
- *.tar.gz) tar xvzf "$1" || return $? ;;
- *.bz2) bunzip2 "$1" || return $? ;;
- *.rar) rar x "$1" || return $? ;;
- *.gz) gunzip "$1" || return $? ;;
- *.tar) tar xvf "$1" || return $? ;;
- *.tbz2) tar xvjf "$1" || return $? ;;
- *.tgz) tar xvzf "$1" || return $? ;;
- *.zip) unzip "$1" || return $? ;;
- *.Z) uncompress "$1" || return $? ;;
- *.7z) 7z x "$1" || return $? ;;
- *) echo "$1 is not of a known archive type"; return 1 ;;
- esac
- }
Add Comment
Please, Sign In to add comment