Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # ex - archive extractor
- # usage: ex <file>
- ex () {
- local args=$@
- local file=${args[@]}
- if [ -f "$file" ] ; then
- case "$file" in
- *.tar.bz2) tar xjf "$file" ;;
- *.tar.gz) tar xzf "$file" ;;
- *.bz2) bunzip2 "$file" ;;
- *.rar) unrar x "$file" ;;
- *.gz) gunzip "$file" ;;
- *.tar) tar xf "$file" ;;
- *.tbz2) tar xjf "$file" ;;
- *.tgz) tar xzf "$file" ;;
- *.zip) unzip "$file" ;;
- *.Z) uncompress "$file";;
- *.7z) 7z x "$file" ;;
- *) echo "'"$file"' cannot be extracted via ex()" ;;
- esac
- else
- echo "'"$file"' is not a valid file"
- exit 1
- fi
- exit 0
- }
- ex "$@"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement