Projects#
Let's play a little game. You're going to create some directories and then play a guessing game. Run this one liner script:
1 | |
Note
Look don't worry about the echo command we're using here, the weird syntax, the use of $RANDOM, and all the other weird stuff that's going on here - that's all for later.
- Create one directory:
number_game- Inside of that directory, I want you to create three more
number,winnerandloser- Can you do this without using
cdto go inside the directory first?
- Can you do this without using
- Inside of that directory, I want you to create three more
- Move into the
number_gamedirectory - Now I want you to guess a number between
1and5(including themselves) - Then run our game:
game - Did you guess the number correctly? Move the file from
number/<number>_<game>towinner/- (sneaky tip: type
numberthen hit Tab+Tab)
- (sneaky tip: type
- You guessed wrong? Move the file from
number/<number>_<game>toloser/ - Player a few rounds
- When you're done, learn how-to count the number of results you got!
Solution
Here's what my session looked like:
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 | |
But what if I played hundreds of games? How do I count the results?
Finalise this section project by deleting everything with a single command. You can do it!