forked from shudarshon/scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
deloldfile.sh
52 lines (40 loc) · 843 Bytes
/
deloldfile.sh
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
#!/bin/bash
#create a file with old date
create(){
touch -d "Thu, 1 March 2018 12:30:00" a
}
#Find and delete files older than 90 days
list(){
find . -mtime +90 -exec ls -ll {} \;
}
#Remove old file
remove(){
find . -mtime +90 -exec rm {} \;
}
#Rename old file
rename(){
find . -mtime +90 -exec mv {} {}.old \;
}
case $1 in
"create")
echo "Creaing new files"
create
;;
"list")
echo "List all the files"
list
;;
"remove")
echo "Remove file"
remove
;;
"rename")
echo "Rename files"
rename
;;
*) echo Run one command from here { create | list | remove | rename };;
esac
#create
#list
#remove
#rename