forked from SVR666/LoaderX-Bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathextract
executable file
·34 lines (31 loc) · 952 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
#!/bin/bash
if [ $# -lt 1 ];then
echo "Usage: `basename $0` FILES"
exit 1
fi
extract () {
arg="$1"
cd "$(dirname "$arg")" || exit
case "$arg" in
*.tar.bz2)
tar xjf "$arg" --one-top-level ;;
*.tar.gz)
tar xzf "$arg" --one-top-level ;;
*.bz2) bunzip2 "$arg" ;;
*.gz) gunzip "$arg" ;;
*.tar) tar xf "$arg" --one-top-level ;;
*.tbz2) tar xjf "$arg" --one-top-level ;;
*.tgz) tar xzf "$arg" --one-top-level ;;
*.zip)
a_dir=`expr "$arg" : '\(.*\).zip'`
7z x "$arg" -o"$a_dir" ;;
*.Z) uncompress "$arg" ;;
*.rar)
a_dir=`expr "$arg" : '\(.*\).rar'` ;
mkdir "$a_dir" ;
7z x "$arg" -o"$a_dir" ;;
*) echo "'$arg' cannot be extracted via extract()" ;;
esac
cd - || exit
}
extract "$1"