-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpage.sh
More file actions
115 lines (87 loc) · 1.38 KB
/
Copy pathpage.sh
File metadata and controls
115 lines (87 loc) · 1.38 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
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
#!/bin/bash
students_file="students.txt"
create_file()
{
if [ ! -f $students_file ]
then
touch $students_file
fi
}
add_student()
{
echo "Enter Student ID:"
read id
echo "Enter Student Name:"
read name
echo "Enter Age:"
read age
echo "Enter Marks:"
read marks
echo "$id,$name,$age,$marks" >> $students_file
echo "Student added successfully"
}
display_students()
{
echo "Student Records"
echo "---------------"
while IFS=',' read id name age marks
do
echo "ID: $id"
echo "Name: $name"
echo "Age: $age"
echo "Marks: $marks"
echo "-------------"
done < $students_file
}
search_student()
{
echo "Enter Student ID:"
read sid
result=$(grep "^$sid," $students_file)
if [ -z "$result" ]
then
echo "Student not found"
else
echo "Student Found"
echo $result
fi
}
delete_students()
{
> $students_file
echo "All records deleted"
}
create_file
while true
do
echo ""
echo "Student Management System"
echo "1. Add Student"
echo "2. Display Students"
echo "3. Search Student"
echo "4. Delete Records"
echo "5. Exit"
echo "Enter choice:"
read choice
case $choice in
1)
add_student
;;
2)
display_students
;;
3)
search_student
;;
4)
delete_students
;;
5)
echo "Program terminated"
exit
;;
*)
echo "Invalid option"
;;
esac
done