-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathextract
executable file
·37 lines (34 loc) · 911 Bytes
/
extract
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/bin/sh
help() {
echo "Extracts the file specified based on the extension"
echo "Stolen from http://dev.gentoo.org/~steev/files/zshrc"
echo "Usage: `basename "$0"` <filename>"
echo
}
case $1 in
'-h'|'--help') help && exit ;;
'') help && exit 1 ;;
esac
if [ -f "$1" ]; then
case "${1}" in
*.tar) tar -xvpf "$1" ;;
*.tar.bz2|*.tbz2) tar -xvjpf "$1" ;;
*.tar.gz|*.tgz) tar -xvzpf "$1" ;;
*.tar.xz) tar -xvJpf "$1" ;;
*.bz2) bunzip2 "$1" ;;
*.gz) gunzip "$1" ;;
*.zip|*.jar) unzip "$1" ;;
*.rar) unrar x "$1" ;;
*.Z) uncompress "$1" ;;
*.gem) gem unpack "$1" ;;
*.rpm) unrpm "$1" ;;
*.7z) 7z e "$1" ;;
*)
echo "Unable to extract '$1': Unknown extension"
exit 1
;;
esac
else
echo "Unable to extract '$1': File not found"
exit 1
fi