View difference between Paste ID: v6U59kTq and gE2WBrN5
SHOW: | | - or go back to the newest paste.
1
2
#!/bin/bash
3
#
4
# 3 Books
5
#
6
7
book1winners=( l848 j854 n839 m843 h864 g866 f871 a889 b887 c882 )
8
book2winners=( g866 n839 h864 )
9
book3winners=( )
10
11
page1=( x801 x802 x803 x804 x805 x806 )
12
page2=( w807 w808 w809 w810 w811 t817 t818 t819 t820 t821 )
13
page3=( r827 r828 r829 r830 r831 l845 l846 l847 l848 j853 j854 j855 j856 )
14
page4=( n837 n838 n839 n840 i857 i858 i859 i860 h861 )
15
page5=( m841 m842 m843 m844 h862 h863 h864 g865 g866 g867 g868 )
16
page6=( p832 p833 p834 p835 p836 k849 k850 k851 k852 f869 f870 f871 f872 )
17
page7=( v812 v813 v814 v815 v816 s822 s823 s824 s825 s826 )
18
page8=( e873 e874 e875 e876 d877 d878 d879 d880 c881 c882 c883 c884 b885 b886 b887 b888 a889 a890 a891 a892 )
19
20
marker=""
21
22
while [ "$marker" != "q" ]
23
do
24
	echo -en "\nStamp marker: " 
25
	read marker
26
27
	if [ "$marker" == "q" ]; then
28
		echo "Quitting..."
29
	elif [ "$marker" == "" ] || [ "$marker" == "h" ]; then
30
		echo "Type a stamp marker or 'q' to quit."
31
	else
32-
        book2dupe=no
32+
33-
        book3dupe=no
33+
	        book2dupe=no
34-
        winner1=no
34+
        	book3dupe=no
35-
        winner2=no
35+
	        winner1=no
36-
        winner3=no
36+
        	winner2=no
37-
        book1match=no
37+
	        winner3=no
38-
        book2match=no
38+
	        book1match=no
39-
        book3match=no
39+
	        book2match=no
40
	        book3match=no
41-
        dupeCheck1=`grep -c $marker book1matches.log`
41+
42-
        dupeCheck2=`grep -c $marker book2matches.log`
42+
	        dupeCheck1=`grep -c $marker book1matches.log`
43-
        dupeCheck3=`grep -c $marker book3matches.log`
43+
	        dupeCheck2=`grep -c $marker book2matches.log`
44
	        dupeCheck3=`grep -c $marker book3matches.log`
45-
        # CHECK FOR DUPLICATES
45+
46-
        if [ "$dupeCheck1" -ne "0" ]; then
46+
 	       # CHECK FOR DUPLICATES
47-
            book1dupe=yes
47+
	        if [ "$dupeCheck1" -ne "0" ]; then
48
	            book1dupe=yes
49-
        if [ "$dupeCheck2" -ne "0" ]; then
49+
	        fi
50-
            book2dupe=yes
50+
 	       if [ "$dupeCheck2" -ne "0" ]; then
51
 	           book2dupe=yes
52-
        if [ "$dupeCheck3" -ne "0" ]; then
52+
 	       fi
53-
            book3dupe=yes
53+
 	       if [ "$dupeCheck3" -ne "0" ]; then
54
 	           book3dupe=yes
55
  	      fi
56-
        # CHECK FOR WINNERS
56+
57-
        if [ "$book1dupe" == "no" ]; then
57+
  	      # CHECK FOR WINNERS
58
  	      if [ "$book1dupe" == "no" ]; then
59
            for i in "${book1winners[@]}"
60
            do
61
                if [ "$marker" == "$i" ]; then
62
                    echo "WINNING MATCH in Book 1"
63
                    winner1=yes
64
                fi
65
            done
66
		fi
67
        if [ "$book2dupe" == "no" ]; then
68
            for i in "${book2winners[@]}"
69
            do
70
                if [ "$marker" == "$i" ]; then
71
                    echo "WINNING MATCH in Book 2"
72
                    winner2=yes
73
                fi
74
            done
75
		fi
76
        if [ "$book3dupe" == "no" ]; then
77
            for i in "${book3winners[@]}"
78
            do
79
                if [ "$marker" == "$i" ]; then
80
                    echo "WINNING MATCH in Book 3"
81
                    winner3=yes
82
                fi
83
            done
84
		fi
85
        
86
        # CHECK FOR MATCHES
87
        if [ "$winner1" == "no" ] && [ "$winner2" == "no" ] && [ "$winner3" == "no" ]; then
88
            # BOOK 1
89
            if [ "$book1dupe" == "no" ]; then
90
                for i in "${page1[@]}"; do
91
                    if [ "$marker" == "$i" ]; then
92
                        echo "New match on Book 1, Page 1"
93
                        book1match=yes
94
                    fi
95
                done
96
                if [ "$book1match" != "yes" ]; then
97
                    for i in "${page2[@]}"; do
98
                        if [ "$marker" == "$i" ]; then
99
                            echo "New match on Book 1, Page 2"
100
                            book1match=yes
101
                        fi
102
                    done
103
                fi
104
                if [ "$book1match" != "yes" ]; then
105
                    for i in "${page3[@]}"; do
106
                        if [ "$marker" == "$i" ]; then
107
                            echo "New match on Book 1, Page 3"
108
                            book1match=yes
109
                        fi
110
                    done
111
                fi
112
                if [ "$book1match" != "yes" ]; then
113
                    for i in "${page4[@]}"; do
114
                        if [ "$marker" == "$i" ]; then
115
                            echo "New match on Book 1, Page 4"
116
                            book1match=yes
117
                        fi
118
                    done
119
                fi
120
                if [ "$book1match" != "yes" ]; then
121
                    for i in "${page5[@]}"; do
122
                        if [ "$marker" == "$i" ]; then
123
                            echo "New match on Book 1, Page 5"
124
                            book1match=yes
125
                        fi
126
                    done
127
                fi
128
                if [ "$book1match" != "yes" ]; then
129
                    for i in "${page6[@]}"; do
130
                        if [ "$marker" == "$i" ]; then
131
                            echo "New match on Book 1, Page 6"
132
                            book1match=yes
133
                        fi
134
                    done
135
                fi
136
                if [ "$book1match" != "yes" ]; then
137
                    for i in "${page7[@]}"; do
138
                        if [ "$marker" == "$i" ]; then
139
                            echo "New match on Book 1, Page 7"
140
                            book1match=yes
141
                        fi
142
                    done
143
                fi
144
                if [ "$book1match" != "yes" ]; then
145
                    for i in "${page8[@]}"; do
146
                        if [ "$marker" == "$i" ]; then
147
                            echo "New match on Book 1, Page 8"
148
                            book1match=yes
149
                        fi
150
                    done
151
                fi
152
            fi
153
            
154
            # BOOK 2
155
            if [ "$book2dupe" == "no" ]; then
156
                for i in "${page1[@]}"; do
157
                    if [ "$marker" == "$i" ]; then
158
                        echo "New match on Book 2, Page 1"
159
                        book2match=yes
160
                    fi
161
                done
162
                if [ "$book2match" != "yes" ]; then
163
                    for i in "${page2[@]}"; do
164
                        if [ "$marker" == "$i" ]; then
165
                            echo "New match on Book 2, Page 2"
166
                            book2match=yes
167
                        fi
168
                    done
169
                fi
170
                if [ "$book2match" != "yes" ]; then
171
                    for i in "${page3[@]}"; do
172
                        if [ "$marker" == "$i" ]; then
173
                            echo "New match on Book 2, Page 3"
174
                            book2match=yes
175
                        fi
176
                    done
177
                fi
178
                if [ "$book2match" != "yes" ]; then
179
                    for i in "${page4[@]}"; do
180
                        if [ "$marker" == "$i" ]; then
181
                            echo "New match on Book 2, Page 4"
182
                            book2match=yes
183
                        fi
184
                    done
185
                fi
186
                if [ "$book2match" != "yes" ]; then
187
                    for i in "${page5[@]}"; do
188
                        if [ "$marker" == "$i" ]; then
189
                            echo "New match on Book 2, Page 5"
190
                            book2match=yes
191
                        fi
192
                    done
193
                fi
194
                if [ "$book2match" != "yes" ]; then
195
                    for i in "${page6[@]}"; do
196
                        if [ "$marker" == "$i" ]; then
197
                            echo "New match on Book 2, Page 6"
198
                            book2match=yes
199
                        fi
200
                    done
201
                fi
202
                if [ "$book2match" != "yes" ]; then
203
                    for i in "${page7[@]}"; do
204
                        if [ "$marker" == "$i" ]; then
205
                            echo "New match on Book 2, Page 7"
206
                            book2match=yes
207
                        fi
208
                    done
209
                fi
210
                if [ "$book2match" != "yes" ]; then
211
                    for i in "${page8[@]}"; do
212
                        if [ "$marker" == "$i" ]; then
213
                            echo "New match on Book 2, Page 8"
214
                            book2match=yes
215
                        fi
216
                    done
217
                fi
218
            fi
219
         
220
            # BOOK 3
221
            if [ "$book3dupe" == "no" ]; then
222
                for i in "${page1[@]}"; do
223
                    if [ "$marker" == "$i" ]; then
224
                        echo "New match on Book 3, Page 1"
225
                        book3match=yes
226
                    fi
227
                done
228
                if [ "$book3match" != "yes" ]; then
229
                    for i in "${page2[@]}"; do
230
                        if [ "$marker" == "$i" ]; then
231
                            echo "New match on Book 3, Page 2"
232
                            book3match=yes
233
                        fi
234
                    done
235
                fi
236
                if [ "$book3match" != "yes" ]; then
237
                    for i in "${page3[@]}"; do
238
                        if [ "$marker" == "$i" ]; then
239
                            echo "New match on Book 3, Page 3"
240
                            book3match=yes
241
                        fi
242
                    done
243
                fi
244
                if [ "$book3match" != "yes" ]; then
245
                    for i in "${page4[@]}"; do
246
                        if [ "$marker" == "$i" ]; then
247
                            echo "New match on Book 3, Page 4"
248
                            book3match=yes
249
                        fi
250
                    done
251
                fi
252
                if [ "$book3match" != "yes" ]; then
253
                    for i in "${page5[@]}"; do
254
                        if [ "$marker" == "$i" ]; then
255
                            echo "New match on Book 3, Page 5"
256
                            book3match=yes
257
                        fi
258
                    done
259
                fi
260
                if [ "$book3match" != "yes" ]; then
261
                    for i in "${page6[@]}"; do
262
                        if [ "$marker" == "$i" ]; then
263
                            echo "New match on Book 3, Page 6"
264
                            book3match=yes
265
                        fi
266
                    done
267
                fi
268
                if [ "$book3match" != "yes" ]; then
269
                    for i in "${page7[@]}"; do
270
                        if [ "$marker" == "$i" ]; then
271
                            echo "New match on Book 3, Page 7"
272
                            book3match=yes
273
                        fi
274
                    done
275
                fi
276
                if [ "$book3match" != "yes" ]; then
277
                    for i in "${page8[@]}"; do
278
                        if [ "$marker" == "$i" ]; then
279
                            echo "New match on Book 3, Page 8"
280
                            book3match=yes
281
                        fi
282
                    done
283
                fi
284
            fi
285
         
286
        fi
287
                        
288
        # LOGGING
289
        if [[ "$book1dupe" == "yes" && "$book2dupe" == "yes" && "$book3dupe" == "yes" ]]; then
290
            echo "All 3 books already have it."
291
            `echo "$marker" >> dupes.log`
292
        elif [[ "$winner1" == "yes" && "$winner2" == "no" && "$winner3" == "no" ]]; then
293
            `echo -e "Winner\t$marker" >> book1matches.log`
294
        elif [[ "$winner1" == "no" && "$winner2" == "yes" && "$winner3" == "no" ]]; then
295
            `echo -e "Winner\t$marker" >> book2matches.log`
296
        elif [[ "$winner1" == "no" && "$winner2" == "no" && "$winner3" == "yes" ]]; then
297
            `echo -e "Winner\t$marker" >> book3matches.log`
298
        elif [[ "$winner1" == "yes" && "$winner2" == "yes" ]] || \
299
             [[ "$winner1" == "yes" && "$winner3" == "yes" ]] || \
300
             [[ "$winner1" == "yes" && "$winner3" == "yes" ]] || \
301
             [[ "$winner1" == "yes" && "$winner2" == "yes" && "$winner3" == "yes" ]]; then
302
            while :
303
            do
304
                echo -n "Which book will the stamp be entered into? [n]: "
305
                read answer
306
                if [ "$answer" == "1" ]; then
307
                    `echo -e "Winner\t$marker" >> book1matches.log`
308
                    break
309
                elif [ "$answer" == "2" ]; then
310
                    `echo -e "Winner\t$marker" >> book2matches.log`
311
                    break
312
                elif [ "$answer" == "3" ]; then
313
                    `echo -e "Winner\t$marker" >> book3matches.log`
314
                    break
315
                fi
316
            done    
317
        elif [[ "$book1match" == "yes" && "$book2match" == "no" && "$book3match" == "no" ]]; then
318
                `echo -e "New Match\t$marker" >> book1matches.log`
319
        elif [[ "$book1match" == "no" && "$book2match" == "yes" && "$book3match" == "no" ]]; then
320
                `echo -e "New Match\t$marker" >> book2matches.log`
321
        elif [[ "$book1match" == "no" && "$book2match" == "no" && "$book3match" == "yes" ]]; then
322
                `echo -e "New Match\t$marker" >> book3matches.log`
323
        elif [[ "$book1match" == "yes" && "$book2match" == "yes" ]] || \
324
             [[ "$book1match" == "yes" && "$book3match" == "yes" ]] || \
325
             [[ "$book2match" == "yes" && "$book3match" == "yes" ]] || \
326
             [[ "$book1match" == "yes" && "$book2match" == "yes" && "$book3match" == "yes" ]]; then
327
            while :
328
            do
329
                echo -n "Which book will the stamp be entered into? [n]: "
330
                read answer
331
                if [ "$answer" == "1" ]; then
332
                    `echo -e "New Match\t$marker" >> book1matches.log`
333
                    break
334
                elif [ "$answer" == "2" ]; then
335
                    `echo -e "New Match\t$marker" >> book2matches.log`
336
                    break
337
                elif [ "$answer" == "3" ]; then
338
                    `echo -e "New Match\t$marker" >> book3matches.log`
339
                    break
340
                fi
341
            done    
342
        elif [[ "$book1dupe" == "no" && "$book2dupe" == "no" && "$book3dupe" == "no" ]] && \
343
             [[ "$winner1" == "no" || "$winner2" == "no" || "$winner3" == "no" ]] && \
344
             [[ "$book1match" == "no" || "$book2match" == "no" || "$book3match" == "no" ]]; then
345
            echo "Something's wrong. Typo somewhere?"
346
        fi
347
    fi
348
done
349
350
exit 0