-
Notifications
You must be signed in to change notification settings - Fork 0
/
commands.sh
executable file
·60 lines (51 loc) · 1.81 KB
/
commands.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
set -e
# Remove previous files generated
rm -f clues.txt id_card_*.txt ultimate_suspect.txt
# Search for the main 3 CLUES
grep -R CLUE mystery > clues.txt
# Found the suspects that has all the 4 id cards found (CLUE:2)
cat mystery/memberships/Museum_of_Bash_History \
mystery/memberships/Terminal_City_Library \
mystery/memberships/Delta_SkyMiles\
mystery/memberships/AAA \
| sort \
| uniq -c \
| grep '4.*' -o \
| cut -d ' ' -f2,3 > id_card_suspects.txt
# Create a list of only men (CLUE:1)
cat mystery/people \
| tr ' ' , \
| cut -d ',' -f1,2 \
| grep ',M' \
| cut -d ',' -f1 > men.txt
# Filter the id_card_suspects considering only men (CLUE: 1)
cat men.txt id_card_suspects.txt \
| sort \
| uniq -c \
| grep '2.*' -o \
| cut -d ' ' -f2,3 > id_card_suspects_men.txt
# Considering the id_card_suspects_men.txt, filter only who has at
# least 6 of Height from vehicle database (CLUE: 1)
cat id_card_suspects_men.txt \
| xargs -L 1 -I@ grep -A 1 @ mystery/vehicles \
| grep -B 1 'Height: 6' \
| grep Owner: \
| cut -d ':' -f2 \
| awk '$1=$1' > id_card_suspects_men_tall.txt
# After found new evidences by interviewing: Annabel Church
# Blue Honda car, it has a specifc plate, but this doesn't matter.
cat id_card_suspects_men_tall.txt \
| xargs -L 1 -I@ grep -B 2 @ mystery/vehicles \
| grep -C 1 'Color: Blue' \
| grep -A 2 'Make: Honda' \
| grep Owner: \
| cut -d : -f2 \
| awk '$1=$1' > ultimate_suspect.txt
# Interview the ultimate_suspect.txt !
echo "FINAL INTERVIEW ----"
cat mystery/interviews/interview-9620713
echo "--------------------"
grep -qi $(md5sum ultimate_suspect.txt | cut -d ' ' -f1) encoded \
&& echo CORRECT\! GREAT WORK, GUMSHOE. \
|| echo SORRY, TRY AGAIN.
echo "Murder: " $(cat ultimate_suspect.txt)