Skip to content

Instantly share code, notes, and snippets.

@draptik
Last active February 4, 2024 17:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save draptik/c68eb475cc6b37df2fcfa5dd121e1246 to your computer and use it in GitHub Desktop.
Save draptik/c68eb475cc6b37df2fcfa5dd121e1246 to your computer and use it in GitHub Desktop.
A solution to clmystery: A Command line murder mystery (https://github.com/veltman/clmystery)

Solving the riddle

A solution to clmystery: Command line murder mystery.

Get all clues

grep "CLUE" crimescene

CLUE: Footage from an ATM security camera is blurry but shows that the perpetrator is a tall male, at least 6'.
CLUE: Found a wallet believed to belong to the killer: no ID, just loose change, and membership cards for AAA, Delta SkyMiles, the local library, and the Museum of Bash History. The cards are totally untraceable and have no name, for some reason.
CLUE: Questioned the barista at the local coffee shop. He said a woman left right before they heard the shots. The name on her latte was Annabel, she had blond spiky hair and a New Zealand accent.

Infos killer:

  • male
  • at least 6'
  • member of AAA, Delta SkyMiles, local library, Museum of Bash History

Infos witness:

  • woman
  • Annabel
  • blond, spiky hair
  • New Zealand accent

Find the witness

grep "Annabel" people
Annabel Sun     F       26      Hart Place, line 40
Oluwasegun Annabel      M       37      Mattapan Street, line 173
Annabel Church  F       38      Buckingham Place, line 179
Annabel Fuglsang        M       40      Haley Street, line 176
  • must be female
    • Annabel Sun F 26 Hart Place, line 40
    • Annabel Church F 38 Buckingham Place, line 179

Check Annabel Sun

head -n 40 streets/Hart_Place | tail -n 1
SEE INTERVIEW #47246024
cat interviews/interview-47246024
Ms. Sun has brown hair and is not from New Zealand.  Not the witness from the cafe.

Check Annabel Church

head -n 179 streets/Buckingham_Place | tail -n 1
SEE INTERVIEW #699607
cat interviews/interview-699607
Interviewed Ms. Church at 2:04 pm.  Witness stated that she did not see anyone she could identify as the shooter, that she ran away as soon as the shots were fired.

However, she reports seeing the car that fled the scene.  Describes it as a blue Honda, with a license plate that starts with "L337" and ends with "9"

Find car

grep "L337" vehicles

License Plate L337ZR9
License Plate L337P89
License Plate L337GX9
License Plate L337QE9
License Plate L337GB9
License Plate L337OI9
License Plate L337X19
License Plate L337539
License Plate L3373U9
License Plate L337369
License Plate L337DV9
License Plate L3375A9
License Plate L337WR9
grep "Honda" vehicles

ups, too many matches, maybe just count the number of matches?

grep "Honda" vehicles | wc -l
327
grep "Blue" vehicles | wc -l
445

How to get a better overview?

grep -A 5 "L337" vehicles

License Plate L337ZR9
Make: Honda    
Color: Red
Owner: Katie Park    
Height: 6'2"
Weight: 189 lbs
--                     
License Plate L337P89
Make: Honda    
Color: Teal
Owner: Mike Bostock  
Height: 6'4"
Weight: 173 lbs
--                     
License Plate L337GX9
Make: Mazda    
Color: Orange
Owner: John Keefe    
Height: 6'4"
Weight: 185 lbs
--                 
License Plate L337QE9
Make: Honda    
Color: Blue
Owner: Erika Owens   
Height: 6'5"
Weight: 220 lbs

## and many more!!!
grep -Pzo '\nLicense Plate L337.*\nMake: Honda\nColor: Blue' vehicles
L337QE9
Make: Honda
Color: BlueL337539
Make: Honda
Color: BlueL337369
Make: Honda
Color: BlueL337DV9
Make: Honda
Color: BlueL3375A9
Make: Honda
Color: BlueL337WR9
Make: Honda
Color: Blue

Blue Hondas with correct license plate using grep -Pzo

grep -Pzo '\nLicense Plate L337.*\nMake: Honda\nColor: Blue\nOwner: .*\nHeight: .*\n' vehicles

License Plate L337QE9
Make: Honda
Color: Blue
Owner: Erika Owens
Height: 6'5"

License Plate L337539
Make: Honda
Color: Blue
Owner: Aron Pilhofer
Height: 5'3"

License Plate L337369
Make: Honda
Color: Blue
Owner: Heather Billings
Height: 5'2"

License Plate L337DV9
Make: Honda
Color: Blue
Owner: Joe Germuska
Height: 6'2"

License Plate L3375A9
Make: Honda
Color: Blue
Owner: Jeremy Bowers
Height: 6'1"

License Plate L337WR9
Make: Honda
Color: Blue
Owner: Jacqui Maher
Height: 6'2"

Blue Hondas with correct license plate using grep and pipes

grep -i "L337.*9" -A6 vehicles | grep -i Honda -B2 -A5 | grep -i Blue -B3 -A4 | grep -i "6'" -B5 -A2

Note: this is also a nice use case for playing with up (ultimate plumber)

Check gender

grep "Jacqui Maher" people

Only the 2 are male and at least 6' tall.

  • Joe Germuska
  • Jeremy Bowers

Check memberships

  • member of
    • AAA,
    • Delta SkyMiles,
    • local library,
    • Museum of Bash History
cat AAA Delta_SkyMiles Terminal_City_Library Museum_of_Bash_History | grep -c "Joe Germuska"
2
cat AAA Delta_SkyMiles Terminal_City_Library Museum_of_Bash_History | grep -c "Jeremy Bowers"
4

Checking if solution is correct

echo "Jeremy Bowers" | $(command -v md5 || command -v md5sum) | grep -qif /dev/stdin encoded && echo CORRECT\! GREAT WORK, GUMSHOE. || echo SORRY, TRY AGAIN.

Alternative using nms (no-more-secrets) and lolcat ;-)

(myvar=$(echo "Jeremy Bowers" | $(command -v md5 || command -v md5sum) | cut -d " " -f1) && grep -qi ${myvar} encoded && echo CORRECT\! GREAT WORK, GUMSHOE. || echo SORRY, TRY AGAIN.) | nms | lolcat

TLDR

Commands used:

  • cat
  • grep
    • -A: after
    • -c: count
    • -Pzo: P extend regex, z zero/nul, o only output matches
  • head
    • -n: lines
  • tail
    • -n: lines
  • wc
    • -l: count lines
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment