#100 Guess the Word Before It's Too Late: Hangman
A classic word game with a macabre metaphor, hangman is nonetheless popular and enjoyable. In the game, you guess letters that might be in the hidden word, and each time you guess incorrectly, the man hanging on the gallows has an additional body part drawn in. Make too many wrong guesses, and the man is fully illustrated, so not only do you lose, but, well, you presumably die too. Not very pleasant!
However, the game itself is fun, and writing it as a shell script proves surprisingly easy.
The Code
#!/bin/sh # hangman - A rudimentary version of the hangman game. Instead of showing a # gradually embodied hanging man, this simply has a bad guess countdown. # You can optionally indicate the ...
Get Wicked Cool Shell Scripts now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.