forked from lzzy12/python-aria-mirror-bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathextract
executable file
·37 lines (34 loc) · 1 KB
/
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/bash
if [ $# -lt 1 ];then
echo "Usage: `basename $0` FILES"
exit 1
fi
extract () {
for arg in $@ ; do
if [ -f $arg ] ; then
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'`
unzip $arg -d $a_dir ;;
*.Z) uncompress $arg ;;
*.rar)
a_dir=`expr $arg : '\(.*\).rar'` ;
mkdir $a_dir ;
rar x $arg $a_dir ;; # 'rar' must to be installed
*) echo "'$arg' cannot be extracted via extract()" ;;
esac
else
echo "'$arg' is not a valid file"
fi
done
}
extract $@