-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrm.sh
More file actions
executable file
·46 lines (45 loc) · 1.2 KB
/
rm.sh
File metadata and controls
executable file
·46 lines (45 loc) · 1.2 KB
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
#!/bin/bash
#
#*****************************************************
#Author: huwei
#QQ: 115185849
#Date: 2020-05-05
#FileName: rm.sh
#Description: replace the "rm" command by mv
#URL: http://nanyuzuo.xin/hexo
#Copyright (c):2020 All rights reserved
#****************************************************
case $1 in
-f|-rf|-r)
if [ $# -ge 2 ];then
DIR=$(mktemp -d /backup/`date +%F_%T`XXX)
while [ "$2" ];do
mv $2 $DIR
shift
done
else
echo "you need input the file/dir name you need to delete"
fi
;;
-nobak)
if [ $# -ge 2 ];then
while [ "$2" ];do
rm -rf $2
shift
done
else
echo "you need input the file/dir name you need to delete"
fi
;;
-h|--help)
echo 'introduction:
this rm is alias for the rm command,you can move the file/dir to /backup/dir
the option "-r", "-f","-rf" is used to move the file or directory
the option "-nobak" is used to delete the file or directory,as the rm command'
;;
*)
echo 'you need add a option:
the option "-r", "-f","-rf" is used to move the file or directory
the option "-nobak" is used to delete the file or directory,as the rm command'
exit 1
esac