-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtpc.sh
More file actions
156 lines (156 loc) · 4.53 KB
/
tpc.sh
File metadata and controls
156 lines (156 loc) · 4.53 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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
clear
BICyan='\033[1;96m' # Cyan
Color_Off='\033[0m' # Text Reset
IRed='\033[0;91m' # Redclear
IGreen='\033[0;92m' # Green
BYellow='\033[1;33m' # Yellow
p=$1
if (($p==1))
then
while true
do
clear
printf "\t\t${BICyan}TEXT PROCESSING COMMANDS${Color_Off}\n\n"
printf "1 -- Search a file for a pattern\n"
printf "2 -- Count lines, words, and characters in specified files\n"
printf "3 -- Display line differences between two files\n"
printf "${IRed}4 -- Exit${Color_Off}\n\n"
printf " Enter your choice:\n\n>>>\t\t "
read a
case "$a" in
1) printf "\nEnter the address of the file\n\n>>>\t\t"
read z
if [ ! -f $z ]
then
printf "\n\t${IRed}File not found - Try Again${Color_Off}"
else
printf "\nEnter the pattern\n\n>>>\t\t"
read p
printf "\n"
grep --color $p $z
if (( $? != 0 )); then
printf "${IRed}The entered pattern does not exist${Color_Off}"
fi
sleep 1s
fi
;;
2) printf "\nEnter the address of the file\n\n>>>\t\t"
read m
if [ ! -f $m ]
then
printf "\n\t${IRed}File not found - Try Again${Color_Off}"
else
printf "Lines in the file\t"
wc -l $m | awk '{print $1}'
printf "Words in the file\t"
wc -w $m | awk '{print $1}'
printf "Characters in the file\t"
wc -c $m | awk '{print $1}'
fi
sleep 1s
;;
3) printf "\nEnter the address of the first file\n\n>>>\t\t"
read f1
if [ ! -f $f1 ]
then
printf "\n\t${IRed}File not found - Try Again${Color_Off}"
else
printf "\nEnter the address of the second file\n\n>>>\t\t"
read f2
if [ ! -f $f2 ]
then
printf "\n\t${IRed}File not found - Try Again${Color_Off}"
else
diff $f1 $f2
sleep 1s
fi
fi
;;
4) bash el.sh
exit
;;
*) printf "${IRed}\n Invalid choice - Try Again\n\n${Color_Off}"
;;
esac
printf "\n\n${BYellow}\t"
read -p "Press enter to continue"
printf "\n\n${Color_Off}"
done
fi
if (($p==0))
then
while true
do
clear
printf "\t\t${BICyan}TEXT PROCESSING COMMANDS${Color_Off}\n\n"
printf "1 -- Search a file for a pattern\n"
printf "2 -- Count lines, words, and characters in specified files\n"
printf "3 -- Display line differences between two files\n"
printf "${IRed}4 -- Quit -- Return to Main Menu${Color_Off}\n\n"
printf " Enter your choice:\n\n>>>\t\t "
read a
case "$a" in
1) printf "\nEnter the address of the file\n\n>>>\t\t"
read z
if [ ! -f $z ]
then
printf "\n\t${IRed}File not found - Try Again${Color_Off}"
else
printf "\nEnter the pattern\n\n>>>\t\t"
read p
printf "\n"
grep --color $p $z
if (( $? != 0 )); then
printf "${IRed}The entered pattern does not exist${Color_Off}"
fi
sleep 1s
fi
;;
2) printf "\nEnter the address of the file\n\n>>>\t\t"
read m
if [ ! -f $m ]
then
printf "\n\t${IRed}File not found - Try Again${Color_Off}"
else
printf "Lines in the file\t"
wc -l $m | awk '{print $1}'
printf "Words in the file\t"
wc -w $m | awk '{print $1}'
printf "Characters in the file\t"
wc -c $m | awk '{print $1}'
fi
sleep 1s
;;
3) printf "\nEnter the address of the first file\n\n>>>\t\t"
read f1
if [ ! -f $f1 ]
then
printf "\n\t${IRed}File not found - Try Again${Color_Off}"
else
printf "\nEnter the address of the second file\n\n>>>\t\t"
read f2
if [ ! -f $f2 ]
then
printf "\n\t${IRed}File not found - Try Again${Color_Off}"
else
diff $f1 $f2
sleep 1s
fi
fi
;;
4) flag=0
break
;;
*) printf "${IRed}\n Invalid choice - Try Again\n\n${Color_Off}"
;;
esac
printf "\n\n${BYellow}\t"
read -p "Press enter to continue"
printf "\n\n${Color_Off}"
done
fi
if (( $flag == 0 ))
then
bash l.sh Loading
bash myHelp.sh
fi