-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript2.sh
More file actions
executable file
·139 lines (113 loc) · 2.05 KB
/
script2.sh
File metadata and controls
executable file
·139 lines (113 loc) · 2.05 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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#bash /bin/bash
RED="\033[31m"
GREEN="\033[32m"
END="\033[0m"
function stat(){
city=`awk '{print $6}' /root/phonebook`
for i in $city;
do
if grep $i /root/cityfile > /dev/null ;
then
continue
else
echo "$i" >> /root/cityfile
fi
done
statWr
sleep 1
}
function statWr(){
cityWrite=`cat /root/cityfile`
for i in $cityWrite
do
counter=`grep -c $i phonebook`
if grep "$counter: $i" /root/citysort>/dev/null;
then
continue
else
echo "$counter: $i" >> /root/citysort
fi
done
cat /root/citysort|sort -rg
}
function mailStat() {
mail=`awk '{print $5}' /root/phonebook | grep -oEi "[@][a-z]+"`
for i in $mail
do
if grep "$i" /root/mail>/dev/null
then
continue
else
echo "$i" >> /root/mail
fi
done
mailF
}
function mailF(){
cmail=`cat /root/mail`
for i in $cmail
do
countermail=`grep -c "$i" /root/phonebook`
echo -e "$i:$countermail"
done
}
function Search(){
while true;
do
clear
echo -e "\tSearch by"
echo -e "$GREEN\t1.Mail"
echo -e "\t2.Phone"
echo -e "\t3.Surname"
echo -e "\t4.City$END"
echo -e "$RED\tBack$END"
read y
case $y in
1)read fin
grep -iE "^[a-z]+ [a-z]+ [0-9]+ [0-9]+ $fin *" /root/phonebook
;;
2)read fin
grep -iE "^[a-z]+ [a-z]+ [0-9]+ $fin *" /root/phonebook ;;
3)read fin
grep -iE "^[a-z]+ $fin+ *" /root/phonebook
;;
4)read fin
grep -iE "^[a-z]+ [a-z]+ [0-9]+ [0-9]+ [0-9|a-z|@|.]+ $fin *" /root/phonebook
;;
'back')
break ;;
'Back')
break ;;
esac
sleep 2;
done
}
function ageStat(){
counter1=`awk '{print $3}' /root/phonebook|grep -c "[0-1][0-88888888]" `
echo "Les than 18:$counter1"
counter2=`awk '{print $3}' /root/phonebook|grep -c "19" `
counter3=`awk '{print $3}' /root/phonebook|grep -c "2[0-9]"`
counter4=$((counter2+$counter3))
echo "19-29:$counter4"
counter5=`awk '{print $3}' /root/phonebook|grep -c "[3-9][0-9]"`
echo "30>:$counter5"
}
while true;
do
echo -e "$GREEN\t1.Statistics$END"
echo -e "$GREEN\t2.Mail statistics$END"
echo -e "$GREEN\t3.Search$END"
echo -e "$GREEN\t4.Age statistic$END"
echo -e $RED "\tExit$END"
read x
case $x in
1)stat;;
2)mailStat;;
3)Search;;
4)ageStat;;
'Exit')break;;
'exit')break;;
esac
sleep 2
clear
done