-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbackadd
executable file
·76 lines (61 loc) · 1.41 KB
/
backadd
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/bin/bash
DEF_BYPY_PATH=$HOME/bin/bypy
DEF_BACKUP_PATH=$DEF_BYPY_PATH/backup
if [ $1x == "-p"x ];then
list_file=($@)
for (( i = 1 ; i < ${#list_file[@]} ; i++ ))
do
cp -rf ${list_file[$i]} $DEF_BACKUP_PATH/
printf "cp -rf [ %s ]files to backup\n" ${list_file[$i]}
done
exit 0;
fi
if [ $# -eq 1 ];then
echo $DEF_BACKUP_PATH
if [ ! -d "$DEF_BACKUP_PATH" ]; then
mkdir $DEF_BACKUP_PATH
fi
cp -rf $1 $DEF_BACKUP_PATH/
printf "cp -rf [ %s ]file backup\n" $1
exit 0;
fi
if [ $# -eq 2 ];
then
if [ $1x == "-x"x ];then
mv -f $2 $DEF_BACKUP_PATH/
printf "mv -f [ %s ]files to backup\n" $2
exit 0;
fi
if [ $1x == "-u"x ];then
cp -rf $2 $DEF_BACKUP_PATH/
printf "cp -rf [ %s ]files to backup\n" $2
exit 0;
fi
if [ -d "$DEF_BYPY_PATH/$1" ]; then
cp -rf $2 $DEF_BYPY_PATH/$1
printf "cp -rf [ %s ]files to %s\n" $2 $1
exit 0;
fi
echo "not found command or opt error"
exit 1;
fi
if [ $# -eq 3 ];
then
if [ ! -d "$DEF_BYPY_PATH/$1" ]; then
mkdir $DEF_BYPY_PATH/$1
fi
if [ $2x == "-x"x ];then
mv -f $3 $DEF_BYPY_PATH/$1/
printf "mv -f [ %s ]files to %d\n" $3 $DEF_BYPY_PATH/$1
exit 0;
fi
if [ $2x == "-u"x ];then
cp -rf $3 $DEF_BYPY_PATH/$1
printf "cp -rf [ %s ]files to %d\n" $3 $DEF_BYPY_PATH/$1
exit 0;
fi
echo "not found command or opt error"
exit 1;
fi
echo "not found command or opt error"