forked from nelsonchung/sync_utility
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcompress.sh
More file actions
executable file
·49 lines (44 loc) · 858 Bytes
/
compress.sh
File metadata and controls
executable file
·49 lines (44 loc) · 858 Bytes
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
38
39
40
41
42
43
44
45
46
47
48
49
echo "Select type"
array=(.tar .gz .tar.gz bz .tar.bz .bz2 .tar.bz2 .xz .tar.xz .Z .tar.Z .tgz .tar.tgz .7z .zip .rar .lha)
for i in `seq 6 7`
do
echo $i"." ${array[$i]}
done
read _type
if [ -z $_type ] ; then
echo "Invaild Type"
exit 0
fi
echo "Select action"
echo "1. Compress"
echo "2. Uncompress"
read _action
if [ "${_action}" != "1" ] && [ "${_action}" != "2" ]; then
echo "Invaild action"
exit 0
fi
if [ "${_action}" == "1" ] && [ "${_type}" != "7" ]; then
echo "Enter dirname"
else
echo "Enter filename"
fi
read _file
case "$_type" in
6)
if [ "${_action}" == "1" ];then
tar jcvf "$_file".tar.bz2 $_file
else
tar jxvf $_file
fi
;;
7)
if [ "${_action}" == "1" ];then
xz -z $_file
else
xz -d $_file
fi
;;
*)
echo "Not supported"
;;
esac