-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTask_Manager.sh
executable file
·153 lines (134 loc) · 2.86 KB
/
Task_Manager.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
#!/bin/bash
# Set task file
TASK_FILE="Task.txt"
LOG_FILE="task_log.txt"
usage() {
# Display menu
Title="TASK MANAGER"
figlet "$Title"
echo "-----------------"
echo "1. Add task"
echo "2. Edit task"
echo "3. View tasks"
echo "4. Delete a task"
echo "5. Exit"
echo "6. View_log"
echo "7. Clear logs"
echo "8. clear Tasks"
echo "9. Reset System"
echo "10. Status"
}
todo() {
read -p "Choose an option:" CHOICE
case $CHOICE in
1)
echo "Enter task:"
read TASK
echo "$TASK" >> "$TASK_FILE"
echo "Task Added"
#for log file
echo "$(date)--You added a task: $TASK " >> $LOG_FILE
read -p "Enter r to refresh: " r
if [ "$r" = 'r' ]; then
usage
todo
fi
;;
2)
echo "Enter task you want to Edit:"
read word
read -p "Task you wish to replace with" new
sed -i "s/$word/$new/" $TASK_FILE
echo "Task Modified"
echo "$(date)-- You edited $word to $new " >> $LOG_FILE
read -p "Enter r to refresh: " r
if [ "$r" = 'r' ]; then
usage
todo
fi
;;
3)
cat -n "$TASK_FILE"
read -p "Enter r to refresh: " r
if [ "$r" = 'r' ]; then
usage
todo
fi
;;
4)
echo "Enter the number of the task you want to remove:"
read TASK_NUM
sed -i "$TASK_NUM d" $TASK_FILE
echo "Task number $TASK_NUM deleted"
echo "$(date)--You deleted task $TASK_NUM " >> $LOG_FILE
read -p "Enter r to refresh: " r
if [ "$r" = 'r' ]; then
usage
todo
fi
;;
5)
exit 0
;;
6)
echo "Actiiviies/Task log"
echo "-------------------"
cat -n "$LOG_FILE"
read -p "Enter r to refresh: " r
if [ "$r" = 'r' ]; then
usage
todo
fi
;;
7)
read -p "Do you really wish to clear your activities?[Y/N]:" Ans
if [ "$Ans" = 'Y' ]; then
rm "$LOG_FILE"
else
echo "Ok request Cancelled"
fi
read -p "Enter r to refresh: " r
if [ "$r" = 'r' ]; then
usage
todo
fi
;;
8)
read -p "Do you wish to clear a tasks? [Y/N]:" Ans
if [ "$Ans" = 'Y' ]; then
rm "$TASK_FILE"
echo "Operation Completed"
else
echo "Ok wish Cancelled"
fi
read -p "Enter r to refresh: " r
if [ "$r" = 'r' ]; then
usage
todo
fi
;;
9)
read -p "Do you which to reset the system? [Y/N]:" Ans
if [ "$Ans" = 'Y' ]; then
rm "$TASK_FILE" "$LOG_FILE"
echo "reset Completed"
else
echo "Ok wish Cancelled"
fi
read -p "Enter r to refresh: " r
if [ "$r" = 'r' ]; then
usage
todo
fi
;;
*) echo "Invalid Input, You are left with 3 attempt"
read -p "Enter r to refresh: " r
if [ "$r" = 'r' ]; then
usage
todo
fi
;;
esac
}
usage
todo