{ "id": "freeCodeCamp/learn-bash-scripting-by-building-five-programs:v1.0.0", "version": "2.0.0", "summary": { "title": "Learn Bash Scripting by Building Five Programs", "description": "> Welcome to the Bash Scripting lessons!" }, "config": { "setup": { "commands": [ "./.freeCodeCamp/setup.sh", "cd .freeCodeCamp && npm install" ], "commits": [ "d1729d3899c17eeece566fe71d05efc208a7004d" ] }, "testRunner": { "command": "npm run programmatic-test", "args": { "tap": "--reporter=mocha-tap-reporter" }, "directory": ".freeCodeCamp" }, "repo": { "uri": "https://github.com/freeCodeCamp/learn-bash-scripting-by-building-five-programs", "branch": "v2.0.0" }, "continue": { "commands": [ "./.freeCodeCamp/setup.sh", "./.freeCodeCamp/reset.sh" ] }, "reset": { "commands": [ "./.freeCodeCamp/setup.sh", "./.freeCodeCamp/reset.sh" ] }, "dependencies": [ { "name": "node", "version": ">=10" } ], "webhook": { "url": "https://api.freecodecamp.org/coderoad-challenge-completed", "events": { "init": false, "reset": false, "step_complete": false, "level_complete": false, "tutorial_complete": true } } }, "levels": [ { "id": "10", "title": "Start the Terminal", "summary": "", "content": "", "steps": [ { "id": "10.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "c7055e012705b9ad2507f88d29235c8e89a730b2" ] }, "content": "**The first thing you need to do is start the terminal.** Do that by clicking the \"hamburger\" menu at the top left of the screen, going to the \"terminal\" section, and clicking \"new terminal\". Once you open a new one, type `echo hello bash` into the terminal and press enter.", "hints": [ "Capitalization matters", "If the tests don't run automatically, \"trash\" all the terminals and try the instructions again" ] } ] }, { "id": "20", "title": "touch questionnaire.sh", "summary": "", "content": "", "steps": [ { "id": "20.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "6837d9633c2074f949f97f2660f750ecd79802cd" ] }, "content": "You can run commands in the terminal or put them in a file to be run as a script. You will be making five small programs to learn some scripting. The first one will be a \"questionnaire\". Use the `touch` command to create `questionnaire.sh` in the `project` folder.", "hints": [ "Type `touch questionnaire.sh` in the terminal and press enter", "Make sure you are in the `project` folder first", "Enter `cd ~/project` in the terminal to get to the project folder if you aren't there" ] } ] }, { "id": "30", "title": "Add echo questionnaire", "summary": "", "content": "", "steps": [ { "id": "30.1", "setup": { "watchers": [ "./questionnaire.sh" ], "commits": [ "69d8cb725b6eb494b76e5cfad8b3473846aad07b" ] }, "content": "To start, open the file in the main editor by clicking the filename in the left side panel.\nThen, add the text `echo hello questionnaire` at the top of the file.", "hints": [ "If the left side panel isn't visible, click the icon that looks like two pieces of paper \nat the top left to open the panel. Then, click on your file to open it", "Add the suggested text to the `questionnaire.sh` file" ] } ] }, { "id": "35", "title": "sh questionnaire.sh", "summary": "", "content": "", "steps": [ { "id": "35.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "e0d7f17ade077b64b799e8f3c24a6ffb4b978a65" ] }, "content": "Your script has one command. Run it with `sh questionnaire.sh` to see what happens. `sh` stands for `shell`.", "hints": [ "Type `sh questionnaire.sh` in the terminal and press enter", "Make sure you are in the `project` folder first", "Enter `cd ~/project` in the terminal to get to the project folder if you aren't there" ] } ] }, { "id": "40", "title": "bash questionnaire.sh", "summary": "", "content": "", "steps": [ { "id": "40.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "6a2a08c856faf28356a7d6f2b8f159a412ce411b" ] }, "content": "Using `sh` to run your script uses the `shell` interpreter. Run your script again with `bash questionnaire.sh` to use the `bash` interpreter. `bash` stands for `bourne-again shell`.", "hints": [ "Type `bash questionnaire.sh` in the terminal and press enter", "Make sure you are in the `project` folder first", "Enter `cd ~/project` in the terminal to get to the project folder if you aren't there" ] } ] }, { "id": "50", "title": "which bash", "summary": "", "content": "", "steps": [ { "id": "50.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "d80dd97b71cd6abd02d2ed4b724ee7c8d25f8b8d" ] }, "content": "The output was the same. There are many interpreters which may not give the output you expect. Find out where the `bash` interpreter is located by entering `which bash` in the terminal.", "hints": [ "Type `which bash` in the terminal and press enter" ] } ] }, { "id": "60", "title": "Add shebang", "summary": "", "content": "", "steps": [ { "id": "60.1", "setup": { "watchers": [ "./questionnaire.sh" ], "commits": [ "e3f077b1b818ede2918a33226460e5f1c583e3b8" ] }, "content": "That's the absolute path to the `bash` interpreter. You can tell your program to use it by placing a `shebang` at the very top of the file like this: `#!`. Add a `shebang` at the very top of your file, the one you want looks like this: `#!/bin/bash`.", "hints": [ "Add `#!/bin/bash` at the top of your `questionnaire.sh` file" ] } ] }, { "id": "70", "title": "./questionnaire", "summary": "", "content": "", "steps": [ { "id": "70.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "2313d3900a07704a6c6f6bed5d7d2ff7d956e1f9" ] }, "content": "Now, instead of using `sh` or `bash` to run your script. You can run it by executing the file and it will default to bash. Execute your script with `./questionnaire.sh`. You will get a permission denied error.", "hints": [ "Type `./questionnaire.sh` in the terminal and press enter", "Make sure you are in the `project` folder first", "Enter `cd ~/project` in the terminal to get to the project folder if you aren't there" ] } ] }, { "id": "80", "title": "ls -l", "summary": "", "content": "", "steps": [ { "id": "80.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "00bf064f1c87ea54174be60ca796c248472f6f19" ] }, "content": "You should have got a permission denied message because you don't have permissions to execute the script. List what's in the `project` folder in long list format with `ls -l` to see the file permissions.", "hints": [ "Type `ls -l` in the terminal and press enter", "Make sure you are in the `project` folder first", "Enter `cd ~/project` in the terminal to get to the project folder if you aren't there" ] } ] }, { "id": "90", "title": "chmod +x questionnaire.sh", "summary": "", "content": "", "steps": [ { "id": "90.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "edb643af58d65a2bef0abb46a89adffdf93de6e8" ] }, "content": "Next to your file is `-rw-r--r--`. All but the first character (`-`) describe permissions different users have with the file. `r` means `read`, `w` means `write`, `x` means `execute`. I don't see an `x` anywhere, so nobody can execute it. Enter `chmod +x questionnaire.sh` in the terminal to give everyone executable permissions.", "hints": [ "Type `chmod +x questionnaire.sh` in the terminal and press enter", "Make sure you are in the `project` folder first", "Enter `cd ~/project` in the terminal to get to the project folder if you aren't there" ] } ] }, { "id": "100", "title": "ls -l", "summary": "", "content": "", "steps": [ { "id": "100.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "5310b0313f2fbe4fb69aea2dc5a962cb56f81e19" ] }, "content": "List what's in the folder again with `ls -l` to see the new permissions.", "hints": [ "Type `ls -l` in the terminal and press enter", "Make sure you are in the `project` folder first", "Enter `cd ~/project` in the terminal to get to the project folder if you aren't there" ] } ] }, { "id": "110", "title": "./questionnaire", "summary": "", "content": "", "steps": [ { "id": "110.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "ce6200621c29675760247ac8cfff085734096a05" ] }, "content": "The `x` was added by each type of user to denote that anyone can execute the file. Run your file again by executing it with `./questionnaire.sh`.", "hints": [ "Type `./questionnaire.sh` in the terminal and press enter", "Make sure you are in the `project` folder first", "Enter `cd ~/project` in the terminal to get to the project folder if you aren't there" ] } ] }, { "id": "140", "title": "Add ls -l", "summary": "", "content": "", "steps": [ { "id": "140.1", "setup": { "watchers": [ "./questionnaire.sh" ], "commits": [ "975fe36751980fe05bc01a7330f4deb38161e584" ] }, "content": "Now it works. In your script, you can add any commands that you would be able to enter in the terminal. Test this by adding the `ls -l` command below your other command.", "hints": [ "Add `ls -l` at the bottom of your `questionnaire.sh` file" ] } ] }, { "id": "150", "title": "./questionnaire", "summary": "", "content": "", "steps": [ { "id": "150.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "032ce400565f170571d69eed514d8d81f157efe3" ] }, "content": "Run the script by executing it again.", "hints": [ "Type `./questionnaire.sh` in the terminal and press enter", "Make sure you are in the `project` folder first", "Enter `cd ~/project` in the terminal to get to the project folder if you aren't there" ] } ] }, { "id": "160", "title": "Delete all - shebang", "summary": "", "content": "", "steps": [ { "id": "160.1", "setup": { "watchers": [ "./questionnaire.sh" ], "commits": [ "699bbe17489321f53b356eb4c72b5ab16823822a" ] }, "content": "Your script printed the result of the two commands as if you entered them in the terminal. Delete everything but the `shebang` from your file so you can start making the questionnaire.", "hints": [ "Only `#!/bin/bash` should remain in your `questionnaire.sh` file" ] } ] }, { "id": "170", "title": "Add QUESTION1 variable", "summary": "", "content": "", "steps": [ { "id": "170.1", "setup": { "watchers": [ "./questionnaire.sh" ], "commits": [ "a0d5b9d8199f61a9c864b65c4f1e3b95eee21f5b" ] }, "content": "Bash has variables, functions, and other things you might be familiar with. You can create a variable with `VARIABLE_NAME=VALUE`. There cannot be any spaces around the equal (`=`) sign. If a variable has any spaces in it, place double quotes around it. Create a variable named `QUESTION1` and set it's value to `\"What's your name?\"`.", "hints": [ "Add `QUESTION1=\"What's your name?\"` at the bottom of your `questionnaire.sh` file" ] } ] }, { "id": "180", "title": "Add echo $QUESTION1", "summary": "", "content": "", "steps": [ { "id": "180.1", "setup": { "watchers": [ "./questionnaire.sh" ], "commits": [ "cbc4c0e5e6abed357990b57c0e64b66edf5c7fd4" ] }, "content": "To use a variable, place `$` in front of it like this: `$VARIABLE_NAME`. Shell scripts run from top to bottom, so you can only use variable below where it's created. Use `echo` to print your variable.", "hints": [ "Add `echo $QUESTION1` at the bottom of your `questionnaire.sh` file" ] } ] }, { "id": "190", "title": "./questionnaire", "summary": "", "content": "", "steps": [ { "id": "190.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "626efba75ba0d8f6cbc2ad4cdb8d492702aaaf16" ] }, "content": "Run the file like you did before to see if it worked.", "hints": [ "Run your file by executing it", "Type `./questionnaire.sh` in the terminal and press enter", "Make sure you are in the `project` folder first", "Enter `cd ~/project` in the terminal to get to the project folder if you aren't there" ] } ] }, { "id": "200", "title": "Add read NAME", "summary": "", "content": "", "steps": [ { "id": "200.1", "setup": { "watchers": [ "./questionnaire.sh" ], "commits": [ "4dae6eafeb5ea31210b27998086a4fc55d023dd1" ] }, "content": "The question was printed. Next, you want to be able to accept input from a user. You can do that with `read` like this: `read VARIABLE_NAME`. This will get user input and store it into a new variable. After you print the question, use `read` to get input and store it in a variable named `NAME`.", "hints": [ "Add `read NAME` at the bottom of your `questionnaire.sh` file" ] } ] }, { "id": "210", "title": "Add echo Hello $NAME", "summary": "", "content": "", "steps": [ { "id": "210.1", "setup": { "watchers": [ "./questionnaire.sh" ], "commits": [ "9317dd685bbefcecac158c2358b42a26b3ce76e8" ] }, "content": "At the bottom of your script, use `echo` to print `Hello .` to the terminal.", "hints": [ "You can use your `NAME` variable like this: `$NAME`", "Use your `$NAME` variable in place of ``", "Don't forget the period", "Add `echo Hello $NAME.` at the bottom of your script" ] } ] }, { "id": "220", "title": "./questionnaire", "summary": "", "content": "", "steps": [ { "id": "220.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "c81cb6d5774fcaedc5ead1ebe5de54e40f2c9f37" ] }, "content": "Run the file again. Type your name and press enter after it asks for it.", "hints": [ "Run your file by executing it", "Type `./questionnaire.sh` in the terminal and press enter", "Make sure you are in the `project` folder first", "Enter `cd ~/project` in the terminal to get to the project folder if you aren't there", "You can press `ctrl+c` to close the program" ] } ] }, { "id": "230", "title": "Add QUESTION2 variable", "summary": "", "content": "", "steps": [ { "id": "230.1", "setup": { "watchers": [ "./questionnaire.sh" ], "commits": [ "696078c01b4aa042cb3a918029c92cc234a1ede6" ] }, "content": "Right below your first variable, create another one named `QUESTION2`. Set the value to, `Where are you from?`. Make sure to put it in double quotes.", "hints": [ "Here's an example: `VARIABLE=\"value\"`", "Add `QUESTION2=\"Where are you from?\"` to your script" ] } ] }, { "id": "240", "title": "Add echo $QUESTION2", "summary": "", "content": "", "steps": [ { "id": "240.1", "setup": { "watchers": [ "./questionnaire.sh" ], "commits": [ "5a3ea50c1862b9b8f3788e29071962594904d8a8" ] }, "content": "After your `read` command, use your new variable to print the next question.", "hints": [ "Use `echo` to print the variable", "Add `echo $QUESTION2` below your `read` command" ] } ] }, { "id": "250", "title": "Add read LOCATION", "summary": "", "content": "", "steps": [ { "id": "250.1", "setup": { "watchers": [ "./questionnaire.sh" ], "commits": [ "eb61d4fac03be52d45c129ccf4b04ae1d64e5fb8" ] }, "content": "Below where the second question is printed, use `read` to get input from the user into a variable named `LOCATION`.", "hints": [ "Here's an example `read VARIABLE_NAME`", "Add `read LOCATION` to your script below `echo $QUESTION2`" ] } ] }, { "id": "260", "title": "Add echo Hello $NAME from $LOCATION", "summary": "", "content": "", "steps": [ { "id": "260.1", "setup": { "watchers": [ "./questionnaire.sh" ], "commits": [ "f113517382ddca8215e89e2d75f48b346028edf7" ] }, "content": "Change the existing response to `Hello from .`.", "hints": [ "Use your two variables in place of `` and ` `", "The command is `echo`, the flag is `--help`", "Type `echo --help` in the terminal and press enter" ] } ] }, { "id": "310", "title": "man echo", "summary": "", "content": "", "steps": [ { "id": "310.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "76aed3123c7f7636f897f35c85de07b14fa69e22" ] }, "content": "That didn't work as I hoped. Another way to find information about a command is with `man`. It stands for `manual` and you can use it like this: `man `. See if there's a manual for `echo`.", "hints": [ "Type `man echo` in the terminal and press enter", "Press enter until you have seen the whole menu" ] } ] }, { "id": "320", "title": "Add echo -e \\n~~ Questionnaire ~~\\n", "summary": "", "content": "", "steps": [ { "id": "320.1", "setup": { "watchers": [ "./questionnaire.sh" ], "commits": [ "7b00267cbc979d62d39392c6f6a4055ec527f4a4" ] }, "content": "At the top of the menu, the `-e` option looks promising. And the `\\n` below it says `new line`. You should take a look at those. In your script, change the title to `echo -e \\n~~ Questionnaire ~~\\n` to see if that prints the empty lines.", "hints": [ "Change the suggested line to `echo -e \\n~~ Questionnaire ~~\\n`" ] } ] }, { "id": "323", "title": "./questionnaire", "summary": "", "content": "", "steps": [ { "id": "323.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "c95ec4f32a9629903aad8c0f9a0cd95c4addbc36" ] }, "content": "Run it to see if it worked. You can press `ctrl+c` to close the program after it starts if you don't want to enter values.", "hints": [ "Run your file by executing it", "Type `./questionnaire.sh` in the terminal and press enter", "Make sure you are in the `project` folder first", "You can press `ctrl+c` to close the program" ] } ] }, { "id": "326", "title": "Change to echo -e \"\\n~~ Questionnaire ~~\\n\"", "summary": "", "content": "", "steps": [ { "id": "326.1", "setup": { "watchers": [ "./questionnaire.sh" ], "commits": [ "87149c5f3041ab4804bbe6acd866e2b8a9d8a2fd" ] }, "content": "It didn't print the empty lines. `echo` will only print empty lines if the value is enclosed in quotes. Place double quotes around the title that gets printed to see if it works.", "hints": [ "Change the suggested line to `echo -e \"\\n~~ Questionnaire ~~\\n\"`" ] } ] }, { "id": "330", "title": "./questionnaire", "summary": "", "content": "", "steps": [ { "id": "330.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "b03cdc968e546bab177dad6ceb397427c8b13f32" ] }, "content": "Run your script again to see if that fixed it.", "hints": [ "Run your file by executing it", "Type `./questionnaire.sh` in the terminal and press enter", "Make sure you are in the `project` folder first", "You can press `ctrl+c` to close the program" ] } ] }, { "id": "340", "title": "Add QUESTION3 variable", "summary": "", "content": "", "steps": [ { "id": "340.1", "setup": { "watchers": [ "./questionnaire.sh" ], "commits": [ "041b3d5602ba49e25aa04fb54cb9875a29ae8ff9" ] }, "content": "Now it's working :smile: Create a `QUESTION3` variable next to the other two, set it's value to `\"What's your favorite coding website?\"`", "hints": [ "Add `QUESTION3=\"What's your favorite coding website?\"` to your `questionnaire.sh` file", "Add it by the other two variables" ] } ] }, { "id": "345", "title": "echo QUESTION3 variable", "summary": "", "content": "", "steps": [ { "id": "345.1", "setup": { "watchers": [ "./questionnaire.sh" ], "commits": [ "e44827108d65c0c681a48a5d93561ac475bea276" ] }, "content": "Use `echo` to print the third question after you `read` the `LOCATION`.", "hints": [ "Add `echo $QUESTION3` below the `read LOCATION`", "Add it to your `questionnaire.sh` file" ] } ] }, { "id": "350", "title": "read WEBSITE", "summary": "", "content": "", "steps": [ { "id": "350.1", "setup": { "watchers": [ "./questionnaire.sh" ], "commits": [ "3d3cfa4d94744740d9052acd427615dc0dd7e362" ] }, "content": "After the question you just printed, add code to read input into a variable named `WEBSITE`.", "hints": [ "Add `read WEBSITE` below the `echo $QUESTION3`" ] } ] }, { "id": "360", "title": "echo final sentence", "summary": "", "content": "", "steps": [ { "id": "360.1", "setup": { "watchers": [ "./questionnaire.sh" ], "commits": [ "b49d95cfbe45dcc3586d871b87413046c2eb0dc7" ] }, "content": "Change the `echo` command of the response to print this sentence instead: `Hello from . I learned that your favorite coding website is !`.", "hints": [ "Replace the `echo Hello $NAME from $LOCATION.` with the suggested sentence", "Use your three variables in place of ``, ``, and ``", "The command should look like this: `echo Hello $NAME from $LOCATION. I learned that your favorite coding website is $WEBSITE!`" ] } ] }, { "id": "363", "title": "./questionnaire", "summary": "", "content": "", "steps": [ { "id": "363.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "f4da0edfe1e2f7d8f5348464e13e85022ffdfac8" ] }, "content": "Run the script and enter values when the program is waiting. Let's see the final output.", "hints": [ "Run your file by executing it", "Type `./questionnaire.sh` in the terminal and press enter", "Make sure you are in the `project` folder first" ] } ] }, { "id": "366", "title": "Add line breaks around final sentence", "summary": "", "content": "", "steps": [ { "id": "366.1", "setup": { "watchers": [ "./questionnaire.sh" ], "commits": [ "20bf7ee45f7e78ffaa9118e6ab29b34e4622e92d" ] }, "content": "One last thing. Change that final response to print an empty line at the beginning of the sentence.", "hints": [ "Use `echo` with the `-e` flag and a new line (`\\n`) character like you did for the title", "Don't forget to put the response in double quotes so it prints the empty line", "Here's an example: `echo -e \"\\n\"`", "Only add a new line at the beginning of the response, not the end", "The final command should look like this: `echo \"\\nHello $NAME from $LOCATION. I learned that your favorite coding website is $WEBSITE!\"`" ] } ] }, { "id": "370", "title": "./questionnaire", "summary": "", "content": "", "steps": [ { "id": "370.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "0ae1eb5b5e03a6fb715457867b6873fd06448b0d" ] }, "content": "Run it one last time and enter values when it asks to see if you like how it looks.", "hints": [ "Run your file by executing it", "Type `./questionnaire.sh` in the terminal and press enter", "Make sure you are in the `project` folder first" ] } ] }, { "id": "380", "title": "touch countdown.sh", "summary": "", "content": "", "steps": [ { "id": "380.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "5032cb849673842d83bb8a44a8bcf9ab433b5b45" ] }, "content": "It looks good. I think you are done with that script for now. The next program will be countdown timer. Use the `touch` command to create a new file named `countdown.sh` in your `project` folder.", "hints": [ "Type `touch countdown.sh` in the terminal and press enter", "Make sure you are in the `project` folder first", "Enter `cd ~/project` in the terminal to get to the project folder if you aren't there" ] } ] }, { "id": "390", "title": "chmod +x countdown.sh", "summary": "", "content": "", "steps": [ { "id": "390.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "113b93619636edfe59b5e197fa3ffb7d0ee38344" ] }, "content": "Give your file executable permissions so you can run it like the other one. It's the `chmod` command with the `+x` flag.", "hints": [ "Here's an example `chmod `", "The value for permissions you want to use is `+x`", "You previously used `chmod +x questionnaire.sh`", "Type `chmod +x countdown.sh` in the terminal and press enter", "Make sure you are in the `project` folder first" ] } ] }, { "id": "400", "title": "Add shebang", "summary": "", "content": "", "steps": [ { "id": "400.1", "setup": { "watchers": [ "./countdown.sh" ], "commits": [ "c7d5cbab419f488c41a512e80c43d6a6f30317a7" ] }, "content": "You want to use the `bash` interpreter again. Add a `shebang` at the top of your new file to denote that.", "hints": [ "A `shebang` looks like this: `#!`", "Enter `which bash` in the terminal to see the path to `bash`", "Look at the `shebang` in your first script to get the syntax", "It should look like this: `#!/bin/bash`", "Add `#!/bin/bash` at the top of your `countdown.sh` file" ] } ] }, { "id": "410", "title": "Add comment", "summary": "", "content": "", "steps": [ { "id": "410.1", "setup": { "watchers": [ "./countdown.sh" ], "commits": [ "0500487839a9afae97cd21861efca7ae74d50517" ] }, "content": "Comments in `bash` look like this: `# `. Add a comment below the `shebang` that says `Program that counts down to zero from a given argument` so people know what it does. Note that the `shebang` is a special case and is not treated like a comment.", "hints": [ "Add `# Program that counts down to zero from a given argument` to your `countdown.sh` file" ] } ] }, { "id": "420", "title": "Add echo $*", "summary": "", "content": "", "steps": [ { "id": "420.1", "setup": { "watchers": [ "./countdown.sh" ], "commits": [ "32e1db7a1de7ce969dda2a3761c49b6072e6ba66" ] }, "content": "Programs can take arguments. You can access them a few different ways with `$`. Add `echo $*` in your script to print all arguments passed to it.", "hints": [ "Add `echo $*` at the bottom of the `countdown.sh` file" ] } ] }, { "id": "425", "title": "./countdown.sh", "summary": "", "content": "", "steps": [ { "id": "425.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "71bb320aa891dbceb778798127ed754a3e321d4b" ] }, "content": "Execute your script with `./countdown.sh`.", "hints": [ "Type `./countdown.sh` in the terminal and press enter", "Make sure you are in the `project` folder first" ] } ] }, { "id": "430", "title": "./countdown.sh arg1 arg2 arg3", "summary": "", "content": "", "steps": [ { "id": "430.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "5fa0d0a01b7de4c295039cd1e5c272fbbc94709e" ] }, "content": "Nothing was printed. Run your script again, but this time add three arguments to the command; `arg1`, `arg2`, and `arg3`. Place them after the command with a space before each one.", "hints": [ "Type `./countdown.sh arg1 arg2 arg3` in the terminal and press enter", "Make sure you are in the `project` folder first" ] } ] }, { "id": "440", "title": "Change to echo $1", "summary": "", "content": "", "steps": [ { "id": "440.1", "setup": { "watchers": [ "./countdown.sh" ], "commits": [ "1d94d313685fabdd8fd6b03f8059bb3b5511f70c" ] }, "content": "`$*` printed all the arguments passed to your script. To access any one of them, use `$`. `arg2` could have been accessed with `$2`. Change your script to `echo` the first argument instead of all the arguments.", "hints": [ "Try running your script with an argument to make sure it’s giving the expected output", "Use `echo $1` to print the second argument", "Change `echo $*` to `echo $1` in your `countdown.sh` file" ] } ] }, { "id": "450", "title": "./countdown.sh arg1 arg2 arg3", "summary": "", "content": "", "steps": [ { "id": "450.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "e1a75faa8f53c223626f99acebf771a1c3d2242d" ] }, "content": "Run your file with `./countdown.sh arg1 arg2 arg3` again.", "hints": [ "Type `./countdown.sh arg1 arg2 arg3` in the terminal and press enter", "Make sure you are in the `project` folder first" ] } ] }, { "id": "460", "title": "help", "summary": "", "content": "", "steps": [ { "id": "460.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "82eeaa9087911dc6abeabd96327f97f789edcc0f" ] }, "content": "Now it just prints the first argument. Your program will accept an argument to count down from. You will test it with an `if` statement to make sure it's a positive integer. I wonder what that syntax would look like. Type `help` in the terminal to see if you can find anything.", "hints": [ "Type `help` in the terminal and press enter" ] } ] }, { "id": "470", "title": "man if", "summary": "", "content": "", "steps": [ { "id": "470.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "b4781ccf2840e5956f6af7ca998b6f9bcfa0b71d" ] }, "content": "This is a list of built-in commands. You should look over it, some of them may look familiar. I see `echo` in there. Another one is `if`. See if you can find out more about it by checking its `man` page.", "hints": [ "Here's an example: `man `", "Type `man if` in the terminal and press enter" ] } ] }, { "id": "480", "title": "help if", "summary": "", "content": "", "steps": [ { "id": "480.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "0399a64cbaf308de884e2131f7cec581a0e9e1b6" ] }, "content": "I guess there isn't a `man` page for it. At the top of the `help` screen, I noticed you can use `help ` to find out more. Yet another way to find out about a command :disappointed_relieved: See if you can find out more about `if` with that method.", "hints": [ "Here's an example `help `", "Type `help if` in the terminal and press enter" ] } ] }, { "id": "490", "title": "Add if arg1 print true", "summary": "", "content": "", "steps": [ { "id": "490.1", "setup": { "watchers": [ "./countdown.sh" ], "commits": [ "b4f678f4f04c58a3445de260caceb227b6f95a0b" ] }, "content": "The syntax is at the top, not all of it is required. Here's another example:\n\n```sh\nif [[ CONDITION ]]\nthen\n STATEMENTS\nfi\n```\n\nRemove the `echo $1` in your script and add an `if` condition that checks `if [[ $1 == arg1 ]]`. In its `then` area, use `echo` to print `true` to the screen. There must be spaces on the inside of the brackets (`[[ ... ]]`) and around the operator (`==`).", "hints": [ "Make sure to remove the `echo $1`", "Add the following to your `countdown.sh` file:\n```sh\nif [[ $1 == arg1 ]]\nthen\n echo true\nfi\n```" ] } ] }, { "id": "500", "title": "./countdown arg1", "summary": "", "content": "", "steps": [ { "id": "500.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "7c31293d270c9783270f699f15c46872bc23c043" ] }, "content": "Notice that the end of the syntax is `fi` (`if` backwards). It should print `true` if you pass `arg1` to your script now. Run the script with `arg1` as the only argument.", "hints": [ "Type `./countdown.sh arg1` in the terminal and press enter", "Make sure you are in the `project` folder first" ] } ] }, { "id": "505", "title": "./countdown !arg1", "summary": "", "content": "", "steps": [ { "id": "505.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "2fa29a4eac4aa6548b70ab1e6067a7233068a18b" ] }, "content": "The `if` condition worked, it printed `true`. Run it again with anything except `arg1` as the first argument.", "hints": [ "Type `./countdown.sh arg2` in the terminal and press enter", "Make sure you are in the `project` folder first" ] } ] }, { "id": "510", "title": "Add else print false", "summary": "", "content": "", "steps": [ { "id": "510.1", "setup": { "watchers": [ "./countdown.sh" ], "commits": [ "077d2e69eb61472889781a847b4daed34675d51f" ] }, "content": "Nothing was printed. One of the optional parts of `if` was an `else` area. You can use it like this:\n\n```sh\nif [[ CONDITION ]]\nthen\n STATEMENTS\nelse\n STATEMENTS\nfi\n```\n\nAdd an `else` to your existing `if` condition. Use `echo` to print `false` if the condition fails.", "hints": [ "Your `if` should look like this:\n```sh\nif [[ $1 == arg1 ]]\nthen\n echo true\nelse\n echo false\nfi\n```" ] } ] }, { "id": "520", "title": "./countdown !arg1", "summary": "", "content": "", "steps": [ { "id": "520.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "f08cbd81b262179420fa37578545757e7e4fed59" ] }, "content": "Run the script again and use anything except `arg1` as the only argument.", "hints": [ "Type `./countdown.sh !arg1` in the terminal and press enter", "Make sure you are in the `project` folder first", "Enter `cd ~/project` in the terminal to get to the project folder if you aren't there" ] } ] }, { "id": "530", "title": "Change if condition -lt 5", "summary": "", "content": "", "steps": [ { "id": "530.1", "setup": { "watchers": [ "./countdown.sh" ], "commits": [ "d096be1f35e2ff0b4c9c0dfbcea20ac5dc6fcca6" ] }, "content": "Now it printed `false`. Your program is expecting an integer to count down from as its argument. You can compare integers inside the brackets (`[[ ... ]]`) of your `if` with `-eq` (equal), `-ne` (not equal), `-lt` (less than), `-le` (less than or equal), `-gt` (greater than), `-ge` (greater than or equal). Change your `if` condition to check if your first argument is less than `5`.", "hints": [ "Make sure there's spaces inside the brackets (`[[ ... ]]`) and around the operator (`-lt`)", "Your `if` condition should look like this: `[[ $1 -lt 5 ]]`", "The whole `if` should look like this:\n```sh\nif [[ $1 -lt 5 ]]\nthen\n echo true\nelse\n echo false\nfi\n```" ] } ] }, { "id": "540", "title": "./countdown 4", "summary": "", "content": "", "steps": [ { "id": "540.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "4706e221bf8aecdaede18b2628d1e15b3ab739e6" ] }, "content": "Run the script again and use `4` as a first argument to make sure it's working.", "hints": [ "Type `./countdown.sh 4` in the terminal and press enter", "Make sure you are in the `project` folder first" ] } ] }, { "id": "542", "title": "./countdown 5", "summary": "", "content": "", "steps": [ { "id": "542.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "d45b629f2cd6537934d11e597a18b3905c7fefb9" ] }, "content": "It printed `true` since your argument was less than `5`. Run it again with `5` as the argument.", "hints": [ "Type `./countdown.sh 5` in the terminal and press enter", "Make sure you are in the `project` folder first" ] } ] }, { "id": "544", "title": "help", "summary": "", "content": "", "steps": [ { "id": "544.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "08667189e830410e95089ae3c6e3fc4244c87de5" ] }, "content": "As expected, that printed `false`. Take a look at that `help` menu again. I want to see if we can find out more about how these expressions work.", "hints": [ "Type `help` in the terminal and press enter" ] } ] }, { "id": "546", "title": "help [[ expression ]]", "summary": "", "content": "", "steps": [ { "id": "546.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "c06a25db53e789394a6ddb22c0f223c502f28764" ] }, "content": "Near the top left, it says `[[ expression ]]`. Those look like the double brackets you are using. See if you can get more info about that with the `help` command like you did with `help if`.", "hints": [ "Here's an example: `help `", "Type `help [[ expression ]]` or `help [[` in the terminal and press enter" ] } ] }, { "id": "548", "title": "help test", "summary": "", "content": "", "steps": [ { "id": "548.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "829f403738dee7080c0c6713a8cead655f1a4ea3" ] }, "content": "It might not be a bad idea to read that. Looks like you can use some, probably familiar, things like `!`, `&&`, and `||` to compare multiple expressions. There's also `==` and `!=` operators for an individual expression. It says something about the `test` built-in command. See if you can bring up the `help` menu for that.", "hints": [ "View the `help` menu of the suggested command like you did for the `help if`", "Here's an example: `help `", "Type `help test` in the terminal and press enter" ] } ] }, { "id": "550", "title": "Change if to [[ $1 -le 5 ]]", "summary": "", "content": "", "steps": [ { "id": "550.1", "setup": { "watchers": [ "./countdown.sh" ], "commits": [ "bc067a2b68e76d0ed4d5a15aacf17b7590c2f6c3" ] }, "content": "That's what I was looking for. At the top are some file operators. There's some string and other operators as well. You should take a look at them. Near the bottom, are the arithmetic operators you used with your `if` condition. Change the condition in your script to check if the first argument is less than or equal to `5`.", "hints": [ "The `if` condition should look like this: `[[ $1 -le 5 ]]`", "Make sure there's spaces inside the brackets (`[[ ... ]]`) and around the operator (`-le`)", "It's the `if` in your `countdown.sh` file" ] } ] }, { "id": "552", "title": "./countdown 5", "summary": "", "content": "", "steps": [ { "id": "552.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "b686a939bd425e40d9d0a653b39c3e2db7844ec3" ] }, "content": "Run the script and use `5` as a first argument again.", "hints": [ "Type `./countdown.sh 5` in the terminal and press enter", "Make sure you are in the `project` folder first" ] } ] }, { "id": "554", "title": "[[ 4 -le 5 ]]", "summary": "", "content": "", "steps": [ { "id": "554.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "d4f02b901417c94206bcb71fa80fb102bb4246bb" ] }, "content": "Now it prints `true`. Remember I said any command can run in the terminal or a script. Try running an expression right in the terminal by entering `[[ 4 -le 5 ]]` in it.", "hints": [ "Enter the suggested expression in the terminal", "Make sure there's spaces inside the brackets (`[[ ... ]]`) and around the operator (`-le`)", "Type `[[ 4 -le 5 ]]` in the terminal and press enter" ] } ] }, { "id": "556", "title": "echo $?", "summary": "", "content": "", "steps": [ { "id": "556.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "ed94e2aff2d7efb90f27b6a985cb6562dd0ff480" ] }, "content": "Nothing happened? Each command has an exit status that can be accessed with `$?`. View the exit status of the **last command** with `echo $?`.", "hints": [ "Type `echo $?` in the terminal and press enter", "Your second to last command should be `[[ 4 -le 5 ]]`. So enter that before `echo $?`" ] } ] }, { "id": "558", "title": "[[ 4 -ge 5 ]]", "summary": "", "content": "", "steps": [ { "id": "558.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "257edd9f345de90e8ab18b2f4c0782aa1c73a3c5" ] }, "content": "The exit status of `0` means it was true, `4` is indeed less or equal to `5`. Try it again with `[[ 4 -ge 5 ]]`.", "hints": [ "Enter the suggested expression in the terminal", "Make sure there's spaces inside the brackets (`[[ ... ]]`) and around the operator (`-ge`)", "Type `[[ 4 -ge 5 ]]` in the terminal and press enter" ] } ] }, { "id": "560", "title": "echo $?", "summary": "", "content": "", "steps": [ { "id": "560.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "55ab86cb5207d4c47dd485204e36f88e6e42f527" ] }, "content": "Use `echo` to view the exit status of the command you just entered.", "hints": [ "Type `echo $?` in the terminal and press enter", "Your second to last command should be `[[ 4 -ge 5 ]]`. So enter that right before `echo $?`" ] } ] }, { "id": "562", "title": "[[ 4 -ge 5 ]]; echo $?", "summary": "", "content": "", "steps": [ { "id": "562.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "c330e8ae81ef028e424b1300519deefdd57861f6" ] }, "content": "It printed `1` this time for false. You can separate commands on a single line with `;`. Enter your last two commands on one line like this: `[[ 4 -ge 5 ]]; echo $?`. It will run the expression, then print the exit status of it since it was the last command.", "hints": [ "Make sure there's spaces inside the brackets (`[[ ... ]]`) and around the operator (`-ge`)", "Type `[[ 4 -ge 5 ]]; echo $?` in the terminal and press enter" ] } ] }, { "id": "564", "title": "[[ 10 -ne 5 ]]; echo $?", "summary": "", "content": "", "steps": [ { "id": "564.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "f8d172acfa090a77f4d686f980f68eb980f2d6c3" ] }, "content": "It's still false. Using the same syntax of `[[ ... ]]; echo$?`, check if `10` is not equal to `5` and print the exit status of the expression on one line.", "hints": [ "Check the `help test` menu to find the `not equal` operator", "It's the `-ne` operator", "You previously used `[[ 4 -ge 5 ]]; echo $?`", "Make sure there's spaces inside the brackets and around the operator", "Type `[[ 10 -ne 5 ]]; echo $?` in the terminal and press enter" ] } ] }, { "id": "566", "title": "bad_command; echo $?", "summary": "", "content": "", "steps": [ { "id": "566.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "8c66e3e4082e5c8fced897708d8b0980b2ad8a9b" ] }, "content": "You can think of an exit status of `0` as true. But it means that the command had zero errors. All commands have an exit status. Using the same syntax, enter `bad_command;` and check its exit status on a single line.", "hints": [ "The syntax looks like this: `; echo $?`", "You previously used `[[ 10 -ne 5 ]]; echo $?`", "Type `bad_command; echo $?` in the terminal and press enter" ] } ] }, { "id": "568", "title": "ls; echo $?", "summary": "", "content": "", "steps": [ { "id": "568.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "63fc31a6ff66f209309e180cf58eb6e14bcf8076" ] }, "content": "`command not found`, with an exit status of `127`. Anything but `0` means there was an error with the command. `bad_command` didn't exist. Try it again with `ls`.", "hints": [ "Use the same syntax you have been using", "Here's an example `; echo $?`", "You previously used `bad_command; echo $?`", "Type `ls; echo $?` in the terminal and press enter" ] } ] }, { "id": "570", "title": "ls -y; echo $?", "summary": "", "content": "", "steps": [ { "id": "570.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "e377095821bf677c401985c5292fc3f4f1d9ed9e" ] }, "content": "The command executed as expected and there were zero errors. So it gave you an exit status of `0`. Try it again with `ls -y`.", "hints": [ "Use the same syntax you have been using", "Here's an example: `; echo $?`", "You previously used `ls; echo $?`", "Type `ls -y; echo $?` in the terminal and press enter" ] } ] }, { "id": "572", "title": "help test", "summary": "", "content": "", "steps": [ { "id": "572.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "c586c030659c56b99f1cad4a227e1fa264967626" ] }, "content": "The `-y` flag doesn't work with `ls` so it gave you an exit status other than `0`, meaning that the command was unsuccessful. View the `help` menu of the `test` command again, I want to see what else is in that list.", "hints": [ "Here's an example: `help `", "Type `help test` in the terminal and press enter" ] } ] }, { "id": "574", "title": "[[ -a countdown.sh ]]; echo $?", "summary": "", "content": "", "steps": [ { "id": "574.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "fda649ff2984edc083d2dd2f4921b405fd6200c7" ] }, "content": "You tried a few of the arithmetic operators, those work for integers. Try one of the file operators. The first one on the list checks if a file exists. Type `[[ -a countdown.sh ]]; echo $?` in the terminal to see if your file exists.", "hints": [ "Enter the suggested commands in the terminal", "Type `[[ -a countdown.sh ]]; echo $?` in the terminal and press enter", "Don't forget the spaces inside the brackets", "Make sure you are in the `project` folder first" ] } ] }, { "id": "575", "title": "[[ -a bad_file.txt ]]; echo $?", "summary": "", "content": "", "steps": [ { "id": "575.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "eaec2237be298f4f5877c3853ae11db6be4aac64" ] }, "content": "The file must exist. It's checking the folder the command is entered from. Try it again with `bad_file.txt`.", "hints": [ "Use the same syntax you have been using", "Here's an example: `; echo $?`", "You previously used `[[ -a countdown.sh ]]; echo $?`", "Type `[[ -a bad_file.txt ]]; echo $?` in the terminal and press enter", "Don't forget the spaces inside the brackets" ] } ] }, { "id": "576", "title": "[[ -x countdown.sh ]]; echo $?", "summary": "", "content": "", "steps": [ { "id": "576.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "26e5ec03be605f844d852d8f56ddcd9b4295de13" ] }, "content": "`bad_file.txt` doesn't exist. I think you're getting the hang of this. Using the same syntax, check if you have permissions to execute your `countdown.sh` file. You may want to look at that menu again.", "hints": [ "View the `help test` menu to find the file operator for checking if a file is executable by you", "It's the `-x` operator", "The syntax you want is `[[ ... ]]; echo $?` to see if the condition is true", "Don't forget the spaces inside the brackets", "Type `[[ -x countdown.sh ]]; echo $?` in the terminal and press enter", "Make sure you are in the `project` folder first" ] } ] }, { "id": "582", "title": "help [[ expression ]]", "summary": "", "content": "", "steps": [ { "id": "582.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "163f74988205a92952f1b196e3b20daddd2ad5d1" ] }, "content": "You played around with a number of the expressions. View the `help [[ expression ]]` menu again that you looked at before to see a few more options. You can view the menu with just `help [[`.", "hints": [ "Enter the suggested command in the terminal", "Type `help [[ expression ]]` or `help [[` in the terminal and press enter" ] } ] }, { "id": "584", "title": "[[ -x countdown.sh && 5 -le 4 ]]; echo $?", "summary": "", "content": "", "steps": [ { "id": "584.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "3d3c2892f160c8f51590b1beb629316c81736c13" ] }, "content": "As I mentioned before, you can test multiple expressions with `&&` and `||`. Enter `[[ -x countdown.sh && 5 -le 4 ]]; echo $?` in the terminal to test the file is executable by you **and** five is less than or equal to four.", "hints": [ "Enter the suggested command in the terminal", "Type `[[ -x countdown.sh && 5 -le 4 ]]; echo $?` in the terminal and press enter", "Make sure there's spaces around the brackets and all the operators" ] } ] }, { "id": "586", "title": "[[ -x countdown.sh || 5 -le 4 ]]; echo $?", "summary": "", "content": "", "steps": [ { "id": "586.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "3d966920ad3e23d5d30ea807ef7520f12498e6bf" ] }, "content": "Both conditions weren't true, so the exit status was `1` for `false`. Try testing the same two conditions with the `or` operator.", "hints": [ "Modify this `[[ -x countdown.sh && 5 -le 4 ]]; echo $?` with the suggestion and enter it in the terminal", "Use the `or` operator from the `help [[ expression ]]` menu", "The `or` operator is `||`", "Type `[[ -x countdown.sh || 5 -le 4 ]]; echo $?` in the terminal and press enter", "Make sure there's spaces around the brackets and all the operators" ] } ] }, { "id": "588", "title": "Change if to [[ $1 -gt 0 ]]", "summary": "", "content": "", "steps": [ { "id": "588.1", "setup": { "watchers": [ "./countdown.sh" ], "commits": [ "22640e91bb5ec9c298e7cb6cc0693ef795dbeb1d" ] }, "content": "One of the conditions was true so it printed `0`. I think that's enough of a detour. Back in your script, change the `if` condition to check if the first argument is **greater than zero** so you can be sure it's something you can count down from.", "hints": [ "Use the `-gt` operator in your `if` condition", "The `if` condition should look like this: `[[ $1 -gt 0 ]]`", "It's in the `countdown.sh` file" ] } ] }, { "id": "590", "title": "Change if !# message", "summary": "", "content": "", "steps": [ { "id": "590.1", "setup": { "watchers": [ "./countdown.sh" ], "commits": [ "c2630e5685a4f1b2ee241041df7a7fd1f075a0b6" ] }, "content": "The condition you added checks if a positive integer was passed as an argument to the script and executes the `then` area. Change the existing `echo` command to print `Include a positive integer as the first argument.` if a positive integer is not used.", "hints": [ "The `else` area should look like this: `echo Include a positive integer as the first argument.`", "The whole `if` condition should look like this:\n```sh\nif [[ $1 -gt 0 ]]\nthen\n echo true\nelse\n echo Include a positive integer as the first argument.\nfi\n```" ] } ] }, { "id": "600", "title": "./countdown 1", "summary": "", "content": "", "steps": [ { "id": "600.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "e2e2e7be210c64523265a3ee75c2ee87227a219f" ] }, "content": "Run your script and use `1` as a first argument to make sure the condition is working.", "hints": [ "Type `./countdown.sh 1` in the terminal and press enter", "Make sure you are in the `project` folder first" ] } ] }, { "id": "610", "title": "./countdown 0", "summary": "", "content": "", "steps": [ { "id": "610.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "601e8acaa39e0975040dca2272ef1b07fe26bc3a" ] }, "content": "Run it again and use anything but a positive integer as the only argument.", "hints": [ "Type `./countdown.sh 0` in the terminal and press enter", "Make sure you are in the `project` folder first" ] } ] }, { "id": "615", "title": "help", "summary": "", "content": "", "steps": [ { "id": "615.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "63b26df4d1981b82aec6b472525cb3f6439d8929" ] }, "content": "Looks like your `if` condition is working. Next, you want to loop over the argument and count down to zero from it. Check the `help` menu to see if there's any commands for this.", "hints": [ "Enter the suggested command in the terminal", "Type `help` in the terminal and press enter" ] } ] }, { "id": "620", "title": "Add for loop for countdown", "summary": "", "content": "", "steps": [ { "id": "620.1", "setup": { "watchers": [ "./countdown.sh" ], "commits": [ "153928d689ffe4dad123e110a15c58fb9d737717" ] }, "content": "There's two `for` loops in there, you want the second one. Here's an example:\n\n```sh\nfor (( i = 10; i > 0; i-- ))\ndo\n echo $i\ndone\n```\n\nThe above creates a variable (`i = 10`), then prints it, subtracts one, and repeats until `i` is not greater than `0`. So it prints `10` through `1`. In the `then` area of your condition, replace the `echo` with a `for` loop that prints from the argument (`$1`) to `1`.", "hints": [ "Set the variable to the value of your argument (`$1`) initially", "Use the same syntax as the example except change the `10` to `$1`", "Don't include any extra commands in the `then` area", "Your `then` area should look like this:\n```sh\nfor (( i = $1; i > 0; i-- ))\ndo\n echo $i\ndone\n```", "The whole `if` condition should look like this:\n```sh\nif [[ $1 -gt 0 ]]\nthen\n for (( i = $1; i > 0; i-- ))\n do\n echo $i\n done\nelse\n echo Include a positive integer as the first argument.\nfi\n```" ] } ] }, { "id": "630", "title": "./countdown 10", "summary": "", "content": "", "steps": [ { "id": "630.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "06895b6ab56b83650651c8efcb03dd67930bba1f" ] }, "content": "Run your script and use `10` as the first argument.", "hints": [ "Type `./countdown.sh 10` in the terminal and press enter", "Make sure you are in the `project` folder first" ] } ] }, { "id": "640", "title": "help", "summary": "", "content": "", "steps": [ { "id": "640.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "2fbbdda735d2d4082d5cee253d36f228472f10ec" ] }, "content": "It works :smile: But I want it to pause for one second between each number. Check the `help` menu again to see if there's any commands that might help.", "hints": [ "Enter the suggested command in the terminal", "Type `help` in the terminal and press enter" ] } ] }, { "id": "650", "title": "ls /", "summary": "", "content": "", "steps": [ { "id": "650.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "4deeb938ad53ac2ffcd2cff5eaf5405244b183bc" ] }, "content": "I'm not seeing the command I was hoping to. These are the built-in commands, where are the rest? Type `ls /` to look around.", "hints": [ "Enter the suggested command in the terminal", "Type `ls /` in the terminal and press enter" ] } ] }, { "id": "660", "title": "ls /bin", "summary": "", "content": "", "steps": [ { "id": "660.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "966e3045d6e18ce9af6770b0d91e7ad944177b04" ] }, "content": "The `/` listed what's in the root of the file system. I see a `bin` folder, `bin` stands for `binary`. View what's in it with `ls /bin`.", "hints": [ "Enter the suggested command in the terminal", "Type `ls /bin` in the terminal and press enter" ] } ] }, { "id": "670", "title": "man sleep", "summary": "", "content": "", "steps": [ { "id": "670.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "0982916478e22aae338712d442262654e707bb41" ] }, "content": "These are some non built-in commands. There's quite a few that should look familiar. One is `bash`, that's the one you used for the `shebang` in your scripts. I see one called `sleep`. View the manual of it.", "hints": [ "View a manual with the `man` command", "Here's an example: `man `", "Enter `man sleep` in the terminal", "Press enter until you have seen the whole menu" ] } ] }, { "id": "675", "title": "sleep 3", "summary": "", "content": "", "steps": [ { "id": "675.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "270e7b2e46e772a1e638f96506afd2bea6af2515" ] }, "content": "At the top, it says you can pause execution for a number of seconds. Try it out by entering `sleep 3` in the terminal.", "hints": [ "Enter the suggested command in the terminal", "Enter `sleep 3` in the terminal" ] } ] }, { "id": "680", "title": "Add sleep to for loop", "summary": "", "content": "", "steps": [ { "id": "680.1", "setup": { "watchers": [ "./countdown.sh" ], "commits": [ "8e337b8eea97cd1853de8ce1a3ad74796cd26237" ] }, "content": "That should work. In your `for` loop, use `sleep` to make the script pause for `1` second after each number is printed.", "hints": [ "Add the suggestion to the `for` loop in your `countdown.sh` file", "Add `sleep 1` after you print `i` in your `for` loop" ] } ] }, { "id": "690", "title": "./countdown 3", "summary": "", "content": "", "steps": [ { "id": "690.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "caeacb82ada82d86f42e27fe3b165f64ff2a436f" ] }, "content": "Run your script and use `3` as the first argument.", "hints": [ "Type `./countdown.sh 3` in the terminal and press enter", "Make sure you are in the `project` folder first" ] } ] }, { "id": "692", "title": "Change to >=", "summary": "", "content": "", "steps": [ { "id": "692.1", "setup": { "watchers": [ "./countdown.sh" ], "commits": [ "06c6d8ebbb5264303f833c6214147e02c190af3c" ] }, "content": "Awesome. Except it should print `0` instead of stopping at `1`. Change the condition in your for loop so that it checks for `i >= 0`.", "hints": [ "Your `for` loop should look like this:\n```sh\nfor (( i = $1; i >= 0; i-- ))\ndo\n echo $i\n sleep 1\ndone\n```", "The whole `if` condition should look like this:\n```sh\nif [[ $1 -gt 0 ]]\nthen\n for (( i = $1; i >= 0; i-- ))\n do\n echo $i\n sleep 1\n done\nelse\n echo Include a positive integer as the first argument.\nfi\n```" ] } ] }, { "id": "694", "title": "./countdown 3", "summary": "", "content": "", "steps": [ { "id": "694.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "95ada381bd7ff967d1151b087f5d3feded386f37" ] }, "content": "Run your script with `3` as the argument again.", "hints": [ "Type `./countdown.sh 3` in the terminal and press enter", "Make sure you are in the `project` folder first" ] } ] }, { "id": "696", "title": "Add echo -e \"title\"", "summary": "", "content": "", "steps": [ { "id": "696.1", "setup": { "watchers": [ "./countdown.sh" ], "commits": [ "d2af9b9ed136a65f744fd37f82b434ba320b4307" ] }, "content": "Excellent. I want it to display a title like the other script. Make it so that it prints `~~ Countdown Timer ~~` before anything else. Include a new line before and after it like you did for the other title.", "hints": [ "Use the `echo` command with the `-e` flag and the new line (`\\n`) character", "Make sure to place the message in double quotes", "Here's an example: `echo -e \"\\n\\n\"`", "Add `echo -e \"\\n~~ Countdown Timer ~~\\n\"` to the `countdown.sh` file after the comment" ] } ] }, { "id": "698", "title": "./countdown 1", "summary": "", "content": "", "steps": [ { "id": "698.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "b83ee9759fb2ebe27a3480dceaff3aac8569923a" ] }, "content": "Run your script and use `1` as the first argument again to see the title.", "hints": [ "Type `./countdown.sh 1` in the terminal and press enter", "Make sure you are in the `project` folder first" ] } ] }, { "id": "700", "title": "Add Multiline comment", "summary": "", "content": "", "steps": [ { "id": "700.1", "setup": { "watchers": [ "./countdown.sh" ], "commits": [ "87f15f0086a2fce2eeaacb3b63a8978bb78d8030" ] }, "content": "This is fun. You can create a multiline comment like this:\n\n```sh\n: '\n comment here\n more comment here\n'\n```\n\nComment out your `for` loop with a multiline comment. I want to try and do this with a `while` loop.", "hints": [ "Comment out the `for` loop in your `countdown.sh` file with a multiline comment", "Make sure there's a space between the `:` and `'`", "Your `for` loop should look like this:\n```sh\n: '\nfor (( i = $1; i >= 0; i-- ))\ndo\n echo $i\n sleep 1\ndone\n'\n```" ] } ] }, { "id": "710", "title": "help while", "summary": "", "content": "", "steps": [ { "id": "710.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "4599e7a4a9a85c6fe9461b7c6aea228c5d63d277" ] }, "content": "View the `help` menu for the `while` command to see if you can find anything.", "hints": [ "Here's an example: `help `", "Enter `help while` in the terminal" ] } ] }, { "id": "730", "title": "Add I variable", "summary": "", "content": "", "steps": [ { "id": "730.1", "setup": { "watchers": [ "./countdown.sh" ], "commits": [ "9315b578a4dbe0083d390df034f752fe1eb032a9" ] }, "content": "It shows the syntax. First, below your comment, create a variable named `I` that is set to the value of your first argument. It will start there, then on each iteration of the `while` loop you can subtract `1` from it until it reaches `0`.", "hints": [ "Add `I=$1` in the `then` area of your `if` statements below the multi-line comment", "The `then` area should look like this:\n```sh\n: '\nfor (( i = $1; i >= 0; i-- ))\ndo\n echo $i\n sleep 1\ndone\n'\nI=$1\n```" ] } ] }, { "id": "740", "title": "Add while loop", "summary": "", "content": "", "steps": [ { "id": "740.1", "setup": { "watchers": [ "./countdown.sh" ], "commits": [ "062b65a7f785bf25323de3d615ebace691d51461" ] }, "content": "The menu showed that you can make a `while` loop like this:\n\n```sh\nwhile [[ CONDITION ]]\ndo\n STATEMENTS\ndone\n```\n\nAdd a `while` loop below the `I` variable you made. The condition should be `$I -ge 0` and you should `echo` the `I` variable in the `do` statements.", "hints": [ "Your `while` loop should look like this:\n```sh\nwhile [[ $I -ge 0 ]]\ndo\n echo $I\ndone\n```" ] } ] }, { "id": "750", "title": "Add (( I-- ))", "summary": "", "content": "", "steps": [ { "id": "750.1", "setup": { "watchers": [ "./countdown.sh" ], "commits": [ "67371e0bce2df565e43da71d7a6c92fa6773d605" ] }, "content": "`I` never changes here, so you would have an infinite loop. You can subtract one from `I` with double parenthesis (`((...))`) and the `--` operator. In your while loop, add `(( I-- ))` after you `echo $I` to subtract one from `I` on each pass.", "hints": [ "Your `while` loop should look like this:\n```sh\nwhile [[ $I -ge 0 ]]\ndo\n echo $I\n (( I-- ))\ndone\n```" ] } ] }, { "id": "760", "title": "Add sleep 1", "summary": "", "content": "", "steps": [ { "id": "760.1", "setup": { "watchers": [ "./countdown.sh" ], "commits": [ "2fe0dd3702f25f06277e9442bdeba653b869eb5f" ] }, "content": "The last thing to do is to add the `sleep` again. In your `while` loop, add the code to make it `sleep` for `1` second. Add the code after the `(( I-- ))`.", "hints": [ "Use the same `sleep 1` you used in the `for` loop", "Your `while` loop should look like this:\n```sh\nwhile [[ $I -ge 0 ]]\ndo\n echo $I\n (( I-- ))\n sleep 1\ndone\n```" ] } ] }, { "id": "770", "title": "./countdown.sh 5", "summary": "", "content": "", "steps": [ { "id": "770.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "21977228375865c92b1e94dc37007afe0c7d6af8" ] }, "content": "Run the script and use 5 as the first argument.", "hints": [ "Type `./countdown.sh 5` in the terminal and press enter", "Make sure you are in the `project` folder first" ] } ] }, { "id": "780", "title": "touch bingo.sh", "summary": "", "content": "", "steps": [ { "id": "780.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "63bd37392b44ad4be26ba2a1523b2b539eb100a5" ] }, "content": "I think the countdown timer is finished. Feel free to try it with some other arguments. The next one is a bingo number generator. Use `touch` to create `bingo.sh` in the same folder as the others.", "hints": [ "Type `touch bingo.sh` in the terminal and press enter", "Make sure you are in the `project` folder first" ] } ] }, { "id": "790", "title": "chmod +x bingo.sh", "summary": "", "content": "", "steps": [ { "id": "790.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "6151a29d58e2774c504e231e8cae4a1a91cfc874" ] }, "content": "Give your file executable permissions like you did for the other two.", "hints": [ "Use the `chmod` command with the `+x` flag", "Here's an example `chmod `", "You previously used `chmod +x countdown.sh`", "Type `chmod +x bingo.sh` in the terminal and press enter" ] } ] }, { "id": "800", "title": "Add shebang", "summary": "", "content": "", "steps": [ { "id": "800.1", "setup": { "watchers": [ "./bingo.sh" ], "commits": [ "0fbdb1bb455d10df9a4ebe2b64ba21cd4973b4ca" ] }, "content": "Add a `shebang` at the top of your new script. It should use `bash` again like other two.", "hints": [ "A `shebang` looks like this: `#!`", "Enter `which bash` in the terminal to see the path to `bash`", "Look at the `shebang` in one of your other scripts to get the syntax", "It should look like this: `#!/bin/bash`", "Add `#!/bin/bash` at the top of your `bingo.sh` file" ] } ] }, { "id": "810", "title": "Add comment", "summary": "", "content": "", "steps": [ { "id": "810.1", "setup": { "watchers": [ "./bingo.sh" ], "commits": [ "b43741774376fc6a74bbd3f339293e7802e06121" ] }, "content": "Add a comment below the `shebang` that says, `Bingo Number Generator`.", "hints": [ "Comments look like this: `# `", "Add `#Bingo Number Generator` below the `shebang`", "Capitalization matters" ] } ] }, { "id": "815", "title": "Add echo -e \"title\"", "summary": "", "content": "", "steps": [ { "id": "815.1", "setup": { "watchers": [ "./bingo.sh" ], "commits": [ "dd08de0c34a05bf03dabd2fe8928caed4ec60366" ] }, "content": "Before I forget, use a single `echo` command to print a title for this program. It should say `~~ Bingo Number Generator ~~` with an empty line before and after it.", "hints": [ "Use the `echo` command with the `-e` flag and the new line (`\\n`) character", "Don't forget the double quotes when using a new line character", "Take a look at one of the title's from a previous file for a hint", "Here's an example: `echo -e \"\\n\\n\"`", "You previously used `echo -e \"\\n~~ Countdown Timer ~~\\n\"`", "Add `echo -e \"\\n~~ Bingo Number Generator ~~\\n\"` below the comment of your `bingo.sh` file" ] } ] }, { "id": "817", "title": "Add NUMBER=5 variable", "summary": "", "content": "", "steps": [ { "id": "817.1", "setup": { "watchers": [ "./bingo.sh" ], "commits": [ "4205be99b9b99e39d4aa59626de92ab354e903a4" ] }, "content": "In your script, create a `NUMBER` variable that equals `5`.", "hints": [ "Here's an example: `VARIABLE_NAME=VALUE`", "Add `NUMBER=5` to the bottom of your `bingo.sh` file" ] } ] }, { "id": "818", "title": "echo $NUMBER", "summary": "", "content": "", "steps": [ { "id": "818.1", "setup": { "watchers": [ "./bingo.sh" ], "commits": [ "8de808502afb1077fa7eacf13d884fa3d4ce4bd3" ] }, "content": "Below your new variable, use `echo` to print it to the screen.", "hints": [ "Here's an example: `echo $`", "Use `NUMBER` in place of ``", "Add `echo $NUMBER` at the bottom of your `bingo.sh` file" ] } ] }, { "id": "819", "title": "./bingo.sh", "summary": "", "content": "", "steps": [ { "id": "819.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "5ded15186d851d102bed32079e4faf5f360de83c" ] }, "content": "Run the script by executing it.", "hints": [ "Type `./bingo.sh` in the terminal and press enter", "Make sure you are in the `project` folder first" ] } ] }, { "id": "820", "title": "printenv", "summary": "", "content": "", "steps": [ { "id": "820.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "fe997bdd726486d4ef3dfb39e0b79044c0e50c52" ] }, "content": "The numbers in bingo go up to 75, each number has a letter from the word `bingo` associated with it. You will need to randomly generate a number between 1 and 75. Bash may have something that can help you here. A shell comes with environment variables. View them by entering `printenv` in the terminal.", "hints": [ "Type `printenv` in the terminal and press enter" ] } ] }, { "id": "822", "title": "echo $LANG", "summary": "", "content": "", "steps": [ { "id": "822.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "8820243355ad8a1fd92d879669abe1bc92a93a6c" ] }, "content": "These are all environment variables, they are predefined and loaded with each shell. Most of them aren’t very relevant, but it’s nice to know they’re there. One of them is `LANG`. Use `echo` to print it in the terminal.", "hints": [ "Here's an example: `echo $`", "Type `echo $LANG` in the terminal and press enter" ] } ] }, { "id": "824", "title": "declare -p", "summary": "", "content": "", "steps": [ { "id": "824.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "161835a7c5d0ca9af25b5e1435d2717d04d01b5b" ] }, "content": "View all variables in the shell with `declare -p`. `-p` stands for `print`", "hints": [ "Type `declare -p` in the terminal and press enter" ] } ] }, { "id": "826", "title": "echo $RANDOM", "summary": "", "content": "", "steps": [ { "id": "826.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "850aba902019cf443232dd772113454fcf192991" ] }, "content": "This list includes all the environment variables, and any others that may have been created in the current shell. There's one named `RANDOM`. Use `echo` to print it in the terminal.", "hints": [ "Here's an example: `echo $`", "Type `echo $RANDOM` in the terminal and press enter" ] } ] }, { "id": "828", "title": "Change to NUMBER=$RANDOM", "summary": "", "content": "", "steps": [ { "id": "828.1", "setup": { "watchers": [ "./bingo.sh" ], "commits": [ "6f6ed3f4a49a45c0d6b32dfa85d321578de9a81f" ] }, "content": "Back in your script, use the `RANDOM` variable to set `NUMBER` to a random number instead of `5`.", "hints": [ "Change `NUMBER=5` to `NUMBER=$RANDOM`" ] } ] }, { "id": "830", "title": "./bingo.sh", "summary": "", "content": "", "steps": [ { "id": "830.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "4c91112db14750f8befec9a5d39f58809f17efa0" ] }, "content": "Run the script a few times in a row to make sure it's working.", "hints": [ "Type `./bingo.sh` in the terminal and press enter two times in a row", "Make sure you are in the `project` folder first" ] } ] }, { "id": "835", "title": "Change to NUMBER=$RANDOM%75", "summary": "", "content": "", "steps": [ { "id": "835.1", "setup": { "watchers": [ "./bingo.sh" ], "commits": [ "2771e94a66c89a972fbbdc899e7d1b9d72b9eb67" ] }, "content": "The `RANDOM` variable will generate a random number between 0 and 32767. You can use the `modulus` operator to make it in the range you want. In your script, change the `NUMBER` variable to `$RANDOM%75`.", "hints": [ "Change `NUMBER=$RANDOM` to `NUMBER=$RANDOM%75`" ] } ] }, { "id": "840", "title": "./bingo.sh", "summary": "", "content": "", "steps": [ { "id": "840.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "44f4eb65480138164cdf2a29455b87942f268801" ] }, "content": "Run the script again.", "hints": [ "Type `./bingo.sh` in the terminal and press enter", "Make sure you are in the `project` folder first" ] } ] }, { "id": "881", "title": "I=0", "summary": "", "content": "", "steps": [ { "id": "881.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "6283e4deccce80d243265e0de666dc964accb096" ] }, "content": "Bash sees everything as a string so it just printed the `%75` part literally. In the terminal, create an `I` variable equal to `0` (zero), so you can play with it and figure out how to do some calculations.", "hints": [ "Type `I=0` in the terminal and press enter" ] } ] }, { "id": "884", "title": "echo $I", "summary": "", "content": "", "steps": [ { "id": "884.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "488f91ab385bcfc1963698db1e13a3e84002a4e0" ] }, "content": "In the terminal, use `echo` to print your new variable.", "hints": [ "Here's an example: `echo $`", "Type `echo $I` in the terminal and press enter" ] } ] }, { "id": "887", "title": "(( I++ ))", "summary": "", "content": "", "steps": [ { "id": "887.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "dac2cfacde326c2dd97336c3dff0c9d6ff10bb76" ] }, "content": "I noticed that you used double parenthesis in the `while` loop of your countdown timer to subtract one from `I`. Type `(( I++ ))` in the terminal to see if anything happens.", "hints": [ "Type `(( I++ ))` in the terminal and press enter" ] } ] }, { "id": "890", "title": "echo $I", "summary": "", "content": "", "steps": [ { "id": "890.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "442feb2fe71b44fff9ebd1f364c7f563bdbe11f3" ] }, "content": "There was no output. Use `echo` to print `I` in the terminal again.", "hints": [ "Type `echo $I` in the terminal and press enter" ] } ] }, { "id": "891", "title": "help let", "summary": "", "content": "", "steps": [ { "id": "891.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "f9d85ebbfc76781810adae611c06841ee59391a0" ] }, "content": "The double parenthesis performed the calculation, changing the value of `I` from `0` to `1`. Enter `help let` in the terminal to see the operators you can use with the double parenthesis.", "hints": [ "Type `help let` in the terminal and press enter" ] } ] }, { "id": "893", "title": "(( I += 10 ))", "summary": "", "content": "", "steps": [ { "id": "893.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "b3b079b976139e42d6fcbf686037ad70cccb3f5b" ] }, "content": "You used several of these now, including in the `for` loop from the countdown timer. Enter `(( I += 10 ))` in the terminal to increment `I` by `10`. Note that you don't need to prepend variables with `$` inside these parenthesis.", "hints": [ "Type `(( I += 10 ))` in the terminal and press enter" ] } ] }, { "id": "896", "title": "echo $I", "summary": "", "content": "", "steps": [ { "id": "896.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "11f648d986767bbf9db1936508987f760d761df5" ] }, "content": "Use `echo` to print your `I` variable again.", "hints": [ "Type `echo $I` in the terminal and press enter." ] } ] }, { "id": "897", "title": "$(( I + 4 ))", "summary": "", "content": "", "steps": [ { "id": "897.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "9db7402e34a7c0d3a739a661fce15dd8e2695a3c" ] }, "content": "It should have printed `11` for the value of `I`. Using the double parenthesis like you have been is good for changing variable values or making comparisons. It makes the calculation in place and provides no output. If you want to make a calculation and do something with the result, add a `$` in front like this: `$(( ... ))`. Type `$(( I + 4 ))` in the terminal to see what happens.", "hints": [ "If it didn't print `11` for `I`, enter `I=11` to set it to `11`", "Type `$(( I + 4 ))` in the terminal and press enter" ] } ] }, { "id": "899", "title": "echo $(( I + 4 ))", "summary": "", "content": "", "steps": [ { "id": "899.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "5bca8205c10de727ccb9f948d101b65085ef06c4" ] }, "content": "It should say, `bash: 15: command not found`. It replaced the command with the result of the calculation. Effectively, trying to run `15` as a command. Enter the same command, but put `echo` in front of it. The command was `$(( I + 4 ))`", "hints": [ "Type `echo $(( I + 4 ))` in the terminal and press enter" ] } ] }, { "id": "902", "title": "echo $I", "summary": "", "content": "", "steps": [ { "id": "902.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "ad012e0eb5dabae4827fe8eaa3a24559e70dd432" ] }, "content": "Again, it replaced the calculation with the result. So it was basically the same as if you entered `echo 15`. Use `echo` to print `I` to the screen again.", "hints": [ "Type `echo $I` in the terminal and press enter" ] } ] }, { "id": "905", "title": "J=$(( I - 6 ))", "summary": "", "content": "", "steps": [ { "id": "905.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "0b819edbbee7321be24d9154f417ba6d7ecd9e3d" ] }, "content": "It should still have printed `11` for `I`. See the hints if it didn't. These double parenthesis with a `$` are how you can assign a variable to some calculation. In the terminal, create a `J` variable, and use the `$(( ... ))` syntax to set its value to `I - 6`.", "hints": [ "If it didn't print `11` for `I`, enter `I=11` to set it to `11`", "Type `J=$(( I - 6 ))` in the terminal and press enter" ] } ] }, { "id": "908", "title": "echo $J", "summary": "", "content": "", "steps": [ { "id": "908.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "dd425c2afee492516d0070525d328a53021c642a" ] }, "content": "Use `echo` to print `J`.", "hints": [ "Here's an example: `echo $`", "Type `echo $J` in the terminal and press enter" ] } ] }, { "id": "911", "title": "echo $(( J * 5 + 25 ))", "summary": "", "content": "", "steps": [ { "id": "911.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "88fdb9cfc32a35d91992bf0513d56f535e21c9db" ] }, "content": "`J` should equal `5`. For some more practice, use `echo` to print the value `J * 5 + 25`.", "hints": [ "Type `echo $(( J * 5 + 25 ))` in the terminal and press enter" ] } ] }, { "id": "912", "title": "echo $J", "summary": "", "content": "", "steps": [ { "id": "912.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "2afb433302f7e0bf44bf1e197b6256ee7feecd74" ] }, "content": "It should have printed `50`. Print `J` with `echo` again.", "hints": [ "Here's an example: `echo $`", "Type `echo $J` in the terminal and press enter" ] } ] }, { "id": "913", "title": "declare -p", "summary": "", "content": "", "steps": [ { "id": "913.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "a05d0b6b4bc0ad590ac8edbb4602b69214050691" ] }, "content": "So, as a reminder, `(( ... ))` will perform a calculation or operation and output nothing. `$(( ... ))` will replace the calculation with the result of it. You made a few variables in this shell, view them with `declare -p`.", "hints": [ "Type `declare -p` in the terminal and press enter" ] } ] }, { "id": "914", "title": "declare -p J", "summary": "", "content": "", "steps": [ { "id": "914.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "b51bfc19e11bd22b9881944f8e9932289a68f263" ] }, "content": "`declare` can be used to create variables, but you are just going to use it to view them for now. If you scroll up a little, you should find your `I` and `J` variables in there. View `J` with `declare -p J`.", "hints": [ "Type `declare -p J` in the terminal and press enter" ] } ] }, { "id": "916", "title": "declare -p RANDOM", "summary": "", "content": "", "steps": [ { "id": "916.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "cb74d3bebe8f7340de49c72efc41f43f9969bc23" ] }, "content": "I saw `RANDOM` in that list, too. View it with `declare -p ` like you did for `J`.", "hints": [ "Type `declare -p RANDOM` in the terminal and press enter" ] } ] }, { "id": "918", "title": "echo $(( RANDOM % 75 ))", "summary": "", "content": "", "steps": [ { "id": "918.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "a647a1019dcf87cfd6df4c2c537011011c194737" ] }, "content": "Okay, I think I finally know how to get the random number for the Bingo Number Generator. Use `echo` and `RANDOM % 75` to print a random number in the terminal.", "hints": [ "Use the `$(( ... ))` syntax to calculate the random number", "Here's an example: `echo $(( ))`", "Type `echo $(( RANDOM % 75 ))` in the terminal and press enter" ] } ] }, { "id": "920", "title": "echo $(( RANDOM % 75 + 1 ))", "summary": "", "content": "", "steps": [ { "id": "920.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "72de400421fcc8783821fc8b65f0fe028f4d1f42" ] }, "content": "One tiny problem, that calculation will give a number between 0 and 74. Enter the same command in the terminal, but add `1` to the calculation to get a random number between 1 and 75.", "hints": [ "Type `echo $(( RANDOM % 75 + 1 ))` in the terminal and press enter" ] } ] }, { "id": "928", "title": "Set NUMBER=$(( RANDOM % 75 + 1))", "summary": "", "content": "", "steps": [ { "id": "928.1", "setup": { "watchers": [ "./bingo.sh" ], "commits": [ "f32145cc8853348b8a838881078d57922dd1ee8d" ] }, "content": "Back in your `bingo.sh` script, change the `NUMBER` variable so that it starts as a random number between 1 and 75 using the syntax you have been practicing.", "hints": [ "Change the `NUMBER` variable to the result of the calculation `RANDOM % 75 + 1`", "Use the `$(( ... ))` syntax to make the calculation", "It should look like this: `NUMBER=$(( RANDOM % 75 + 1 ))`" ] } ] }, { "id": "930", "title": "run ./bingo.sh", "summary": "", "content": "", "steps": [ { "id": "930.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "fea437ad85a8ab3c71abd2cafc003d42a66067c0" ] }, "content": "Run your script a few times in a row to make sure it's working.", "hints": [ "Type `./bingo.sh` in the terminal and press enter", "Make sure you are in the `project` folder first", "Run it at least two times in a row" ] } ] }, { "id": "940", "title": "Add TEXT variable", "summary": "", "content": "", "steps": [ { "id": "940.1", "setup": { "watchers": [ "./bingo.sh" ], "commits": [ "6b44b7e719cdac71644faf871f71de8cd7b7cdb8" ] }, "content": "Next, create a `TEXT` variable and set the value to `\"The next number is, \"`. When the script is finished, the output will be something like `The next number is B:15`.", "hints": [ "Make sure there's a space after the comma", "Add `TEXT=\"The next number is, \"` to the `bingo.sh` file" ] } ] }, { "id": "945", "title": "help let", "summary": "", "content": "", "steps": [ { "id": "945.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "e2284c78eed3b83639d00cf6fcffbfc91ce5483f" ] }, "content": "The letter that goes with the random number depends on what the number is. If it's 15 or less, it will be a `B`. I saw some comparisons in the `help let` menu, take a look at it again.", "hints": [ "Type `help let` in the terminal and press enter" ] } ] }, { "id": "950", "title": "Add first if <= 15", "summary": "", "content": "", "steps": [ { "id": "950.1", "setup": { "watchers": [ "./bingo.sh" ], "commits": [ "904f5a419281ba14098c38e5c06942b3259043df" ] }, "content": "You used the double square brackets with your `if` statement in the last program, but you can use the double parenthesis with these operators as well. In your script, create an `if` statement that uses double parenthesis for the condition. Check if the number variable is less than or equal to 15. If it is, use your two variables to print `The next number is, B:`.", "hints": [ "Make sure you only have two `echo` statements in your script, the title being one of them", "Here's an example of how your `if` statement should look:\n```sh\nif (( CONDITION ))\nthen\n STATEMENTS\nfi\n```", "The condition you want is `(( NUMBER <= 15 ))`", "In the statements area, use `echo` and your two variables to print `The next number is, B:`", "The statements area should look like this: `echo $TEXT B:$NUMBER`", "The whole `if` statement should look like this:\n```sh\nif (( NUMBER <= 15 ))\nthen\n echo $TEXT B:$NUMBER\nfi\n```" ] } ] }, { "id": "960", "title": "Add elif -le 30", "summary": "", "content": "", "steps": [ { "id": "960.1", "setup": { "watchers": [ "./bingo.sh" ], "commits": [ "c12ab6f08ab57c445b13b525a04797673bf86181" ] }, "content": "`if` statements can have an \"else if\" area like this:\n```sh\nif (( CONDITION ))\nthen\n STATEMENTS\nelif [[ CONDITION ]]\nthen\n STATEMENTS\nfi\n```\n\nUsing the double square brackets this time, add an `elif` condition that checks if the number variable is less than or equal to `30`. If it is, use your two variables again to print `The next number is, I:`", "hints": [ "View the `help test` menu to see the operators you can use with the double square brackets", "The condition you want is `[[ $NUMBER -le 30 ]]`. Don't forget the `$`", "In the statements area, use `echo` and your two variables to print `The next number is, I:`", "The statements area should look like this: `echo $TEXT I:$NUMBER`", "The `elif` area should look like this:\n```sh\nelif [[ $NUMBER -le 30 ]]\nthen\n echo $TEXT I:$NUMBER\nfi\n```", "The whole `if` statement should look like this:\n```sh\nif (( NUMBER <= 15 ))\nthen\n echo $TEXT B:$NUMBER\nelif [[ $NUMBER -le 30 ]]\nthen\n echo $TEXT I:$NUMBER\nfi\n```" ] } ] }, { "id": "970", "title": "Add elif < 46", "summary": "", "content": "", "steps": [ { "id": "970.1", "setup": { "watchers": [ "./bingo.sh" ], "commits": [ "154979ffadbce61cc7e66f9fe01f7f915f424f0d" ] }, "content": "You can add as many `elif` sections to an `if` statement as you want. Add another `elif`, below the last, one that uses the double parenthesis to check if the number variable is less than 46. If it is, use your two variables to print `The next number is, N:`", "hints": [ "View the `help let` menu to see the operators you can use with the double parenthesis", "The operator you want it `<`", "You can add another `elif` like this:\n```sh\nif CONDITION\nthen\n STATEMENTS\nelif CONDITION\nthen\n STATEMENTS\nelif CONDITION\nthen\n STATEMENTS\nfi\n```", "The condition you want is `(( NUMBER < 46 ))`", "In the statements area, use `echo` and your two variables to print `The next number is, N:`", "The statements area should look like this: `echo $TEXT N:$NUMBER`", "This `elif` area should look like this:\n```sh\nelif (( NUMBER < 46 ))\nthen\n echo $TEXT N:$NUMBER\nfi\n```", "The whole `if` statement should look like this:\n```sh\nif (( NUMBER <= 15 ))\nthen\n echo $TEXT B:$NUMBER\nelif [[ $NUMBER -le 30 ]]\nthen\n echo $TEXT I:$NUMBER\nelif (( NUMBER < 46 ))\nthen\n echo $TEXT N:$NUMBER\nfi\n```" ] } ] }, { "id": "980", "title": "Add elif -lt 61", "summary": "", "content": "", "steps": [ { "id": "980.1", "setup": { "watchers": [ "./bingo.sh" ], "commits": [ "f999eade741d4626b8b61b5d4c85d1e590e1b8fe" ] }, "content": "Run your script if you want to see the output. It should print one of the sentences if the random number is less than 46. It may take a couple tries. Add another `elif`, below the last one, that uses double square brackets to check if the number variable is less than 61. If it is, use your two variables to print `The next number is, G:`", "hints": [ "View the `help test` menu to see the operators you can use with the double square brackets", "The operator you want it `-lt`", "The condition you want is `[[ $NUMBER -lt 61 ]]`. Don't forget the `$`", "The statements area should look like this: `echo $TEXT G:$NUMBER`", "This `elif` area should look like this:\n```sh\nelif [[ $NUMBER -lt 61 ]]\nthen\n echo $TEXT G:$NUMBER\nfi\n```", "The whole `if` statement should look like this:\n```sh\nif (( NUMBER <= 15 ))\nthen\n echo $TEXT B:$NUMBER\nelif [[ $NUMBER -le 30 ]]\nthen\n echo $TEXT I:$NUMBER\nelif (( NUMBER < 46 ))\nthen\n echo $TEXT N:$NUMBER\nelif [[ $NUMBER -lt 61 ]]\nthen\n echo $TEXT G:$NUMBER\nfi\n```" ] } ] }, { "id": "990", "title": "Add else", "summary": "", "content": "", "steps": [ { "id": "990.1", "setup": { "watchers": [ "./bingo.sh" ], "commits": [ "77e5baf13906b6c03340fa0c896ecc686e9c91cb" ] }, "content": "One more case to handle. Add an `else` at the bottom of the `if` that uses your two variables to print `The next number is, O:`.", "hints": [ "View the `if/else` in your `countdown.sh` file to see how you did it before", "You don't need a condition or the `then` on this one", "Here's an example:\n```sh\nif CONDITION\nthen\n STATEMENTS\nelif CONDITION\nthen\n STATEMENTS\n...\nelse\n STATEMENTS\nfi\n```", "The `else` area should look like this:\n```sh\nelse\n echo $TEXT O:$NUMBER\n```", "The whole `if` should look like this:\n```sh\nif (( NUMBER <= 15 ))\nthen\n echo $TEXT B:$NUMBER\nelif [[ $NUMBER -le 30 ]]\nthen\n echo $TEXT I:$NUMBER\nelif (( NUMBER < 46 ))\nthen\n echo $TEXT N:$NUMBER\nelif [[ $NUMBER -lt 61 ]]\nthen\n echo $TEXT G:$NUMBER\nelse\n echo $TEXT O:$NUMBER\nfi\n```" ] } ] }, { "id": "1000", "title": "./bingo.sh", "summary": "", "content": "", "steps": [ { "id": "1000.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "75648697077385dce332c4981809aa7e943c6ac1" ] }, "content": "Run your script a few times and make sure it's working.", "hints": [ "Type `./bingo.sh` in the terminal and press enter", "Make sure you are in the `project` folder first", "Run it at least two times in a row" ] } ] }, { "id": "1010", "title": "touch fortune.sh", "summary": "", "content": "", "steps": [ { "id": "1010.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "091912f82fb73a336dec8b75504aaa4ee6dd56c3" ] }, "content": "I think the generator is done :smile: The next project is a fortune teller. Use the `touch` command to create `fortune.sh` in the same folder as the other scripts.", "hints": [ "Type `touch fortune.sh` in the terminal and press enter", "Make sure you are in the `project` folder first" ] } ] }, { "id": "1020", "title": "chmod +x fortune.sh", "summary": "", "content": "", "steps": [ { "id": "1020.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "8578b65ca826b3b9ad36f2867f96013e961db1ff" ] }, "content": "Give your file executable permissions.", "hints": [ "Use the `chmod` command with the `+x` flag", "Here's an example `chmod `", "You previously used `chmod +x bingo.sh`", "Type `chmod +x fortune.sh` in the terminal and press enter" ] } ] }, { "id": "1030", "title": "Add shebang", "summary": "", "content": "", "steps": [ { "id": "1030.1", "setup": { "watchers": [ "./fortune.sh" ], "commits": [ "0610814a83c882ce106c9b244dab2ed3138f07fe" ] }, "content": "Add a `shebang` at the top of your new file that uses `bash` again.", "hints": [ "A `shebang` looks like this: `#!`", "Enter `which bash` in the terminal to see the path to `bash`", "Look at the `shebang` in one of your other scripts to get the syntax", "It should look like this: `#!/bin/bash`", "Add `#!/bin/bash` at the top of your `fortune.sh` file" ] } ] }, { "id": "1040", "title": "Add comment", "summary": "", "content": "", "steps": [ { "id": "1040.1", "setup": { "watchers": [ "./fortune.sh" ], "commits": [ "86b1e46e963430e14617c0163ba5ec7af1ff0472" ] }, "content": "Add comment `Program to tell a persons fortune`", "hints": [ "Comments look like this: `# `", "Add `#Program to tell a persons fortune` below the `shebang`", "Capitalization matters" ] } ] }, { "id": "1050", "title": "Add echo \"title\"", "summary": "", "content": "", "steps": [ { "id": "1050.1", "setup": { "watchers": [ "./fortune.sh" ], "commits": [ "162216a6339368c37087b5a7fd80d2af3becec9d" ] }, "content": "Add a title for this one like the others. This one should say `~~ Fortune Teller ~~`. Don't forget the empty line before and after it.", "hints": [ "Print the whole title and the empty lines with a single `echo` command", "Use the `echo` command with the `-e` flag and the new line (`\\n`) character", "Don't forget to put it in double quotes", "Take a look at one of the title's from a previous file for a hint", "Here's an example: `echo -e \"\\n\\n\"`", "You previously used `echo -e \"\\n~~ Bingo Number Generator ~~\\n\"`", "Add `echo -e \"\\n~~ Fortune Teller ~~\\n\"` below the comment of your `fortune.sh` file" ] } ] }, { "id": "1060", "title": "./fortune.sh", "summary": "", "content": "", "steps": [ { "id": "1060.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "4268c1c887317dd1ba2effa1893b2b7911ab51ca" ] }, "content": "Run the file once to make sure it's working.", "hints": [ "Type `./fortune.sh` in the terminal and press enter", "Make sure you are in the `project` folder first" ] } ] }, { "id": "1070", "title": "ARR=(\"a\" \"b\" \"c\")", "summary": "", "content": "", "steps": [ { "id": "1070.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "78dbeb83aeee77fa37c9ec3f4d128e1bbbb7dab3" ] }, "content": "This program will have an array of responses. One will be printed randomly after a user inputs a question. Practice first :smile: In the terminal, create an array like this: `ARR=(\"a\" \"b\" \"c\")`", "hints": [ "Type the suggested command in the terminal", "Type `ARR=(\"a\" \"b\" \"c\")` in the terminal and press enter" ] } ] }, { "id": "1080", "title": "echo ${ARR[1]}", "summary": "", "content": "", "steps": [ { "id": "1080.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "32ec4d1f6be27850c3562f09f6e5d8366bdfac1b" ] }, "content": "Each variable in the array is like any other variable, just combined into a single variable. In the terminal, print the second item in the array with `echo ${ARR[1]}`. Note that the first item would be index zero.", "hints": [ "Type `echo ${ARR[1]}` in the terminal" ] } ] }, { "id": "1090", "title": "echo ${ARR[@]}", "summary": "", "content": "", "steps": [ { "id": "1090.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "dd9881a7a38b07bf1b69d1b78d305323d72b0278" ] }, "content": "If you recall, you were able to print all the arguments to your `countdown.sh` script with `echo $*`. `echo $@` would have worked as well. Similarly, you can use the `*` or `@` to print your whole array. In the terminal, use `echo` to print all the items in your array.", "hints": [ "Here's an example `echo ${ARR[]}`", "Type `echo ${ARR[@]}` in the terminal and press enter" ] } ] }, { "id": "1100", "title": "declare -p ARR", "summary": "", "content": "", "steps": [ { "id": "1100.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "8cc2db6813a9f2aa7706e9e37f80ff80d7074340" ] }, "content": "The variable must be in that `declare` list. View your array variable using the `declare` command and the `-p` flag.", "hints": [ "Here's an example: `declare -p `", "Type `declare -p ARR` in the terminal" ] } ] }, { "id": "1110", "title": "Add RESPONSES array", "summary": "", "content": "", "steps": [ { "id": "1110.1", "setup": { "watchers": [ "./fortune.sh" ], "commits": [ "7bc1529027c76784d301d89026e2d8c8eb66fdfe" ] }, "content": "The `-a` next to it stands for `array`. In your script, create an array named `RESPONSES`. Give it these six values: `Yes`, `No`, `Maybe`, `Outlook good`, `Don't count on it`, and `Ask again later`.", "hints": [ "Here's an example: `VARIABLE=(value value ...)`", "Make sure any values with spaces are in proper quotes", "You created your other array with `ARR=(\"a\" \"b\" \"c\")`", "Add `RESPONSES=(\"Yes\" \"No\" \"Maybe\" \"Outlook good\" \"Don't count on it\" \"Ask again later\")` in your script" ] } ] }, { "id": "1120", "title": "echo ${RESPONSES[5]}", "summary": "", "content": "", "steps": [ { "id": "1120.1", "setup": { "watchers": [ "./fortune.sh" ], "commits": [ "ec1b52c89e4bb4bcf126a691a26117d72b79706c" ] }, "content": "In your script, use `echo` to print the last item in the array.", "hints": [ "Here's an example `echo ${ARR[]}`", "Remember that the first item starts at zero", "Add `echo ${RESPONSES[5]}` to your `fortune.sh` file" ] } ] }, { "id": "1130", "title": "./fortune.sh", "summary": "", "content": "", "steps": [ { "id": "1130.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "21e70693d37e3ea44e207afb7643b806433b1de5" ] }, "content": "Run it to see the output.", "hints": [ "Type `./fortune.sh` in the terminal and press enter", "Make sure you are in the `project` folder first" ] } ] }, { "id": "1140", "title": "Add N=$(( RANDOM % 6 ))", "summary": "", "content": "", "steps": [ { "id": "1140.1", "setup": { "watchers": [ "./fortune.sh" ], "commits": [ "bbc6d929d41329cb46cc99ea5fb7a58f3f63a637" ] }, "content": "You will randomly print one of the values. In your script, create a variable named `N`. Set it equal to a random number between `0` and `5`, the first and last index of the array.", "hints": [ "Use the modulus (`%`) operator and `6` to get a number between `0` and `5`", "Look at the random number you created in the `bingo.sh` file for a hint", "Here's an example: `VARIABLE=$(( ))`", "Calculate a random number in the range you want with `RANDOM % 6`", "Add `N=$(( RANDOM % 6 ))` to the script" ] } ] }, { "id": "1150", "title": "Change to echo ${RESPONSES[$N]}", "summary": "", "content": "", "steps": [ { "id": "1150.1", "setup": { "watchers": [ "./fortune.sh" ], "commits": [ "d2daa5cbf01a3464148765c9353612e50a2d9a4c" ] }, "content": "Change your `echo` command to print the item in the array whose index is the random number you generated.", "hints": [ "Use your `$N` variable as the index where you print an item from the array", "Don't forget that scripts run from top to bottom, so you can't use any variables before they are created", "Change the `echo` line to `echo ${RESPONSES[$N]}`" ] } ] }, { "id": "1160", "title": "help", "summary": "", "content": "", "steps": [ { "id": "1160.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "851f3b8c422d74d0bddddb0b7eb34c4081f7b3f9" ] }, "content": "You will create a function to generate an answer. Check the `help` menu to see if you can find anything.", "hints": [ "Enter the suggested command in the terminal", "Type `help` in the terminal" ] } ] }, { "id": "1170", "title": "help function", "summary": "", "content": "", "steps": [ { "id": "1170.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "c018988958dc91a4beecdb1a0458d7e3d2ab1288" ] }, "content": "See any that might help? There's one that says `function`. See if you can find out more about it.", "hints": [ "Use the `help` command to find out more", "Here's an example: `help `", "Type `help function` in the terminal" ] } ] }, { "id": "1180", "title": "Add GET_FORTUNE function", "summary": "", "content": "", "steps": [ { "id": "1180.1", "setup": { "watchers": [ "./fortune.sh" ], "commits": [ "327d85a12a6a2d4c43aea195a9959ae188da1fbc" ] }, "content": "It looks like you can create a function like this:\n\n```sh\nFUNCTION_NAME() {\n STATEMENTS\n}\n```\n\nAdd an empty function named `GET_FORTUNE` to your script. Make sure the response you are printing is the last thing in the script.", "hints": [ "Add this to your script:\n```sh\nGET_FORTUNE() {}\n```", "Your `echo ${RESPONSES[$N]}` command should be at the bottom of the file" ] } ] }, { "id": "1190", "title": "Add echo Ask a yes or no question", "summary": "", "content": "", "steps": [ { "id": "1190.1", "setup": { "watchers": [ "./fortune.sh" ], "commits": [ "e12272e90ff5acf749a850c5d7bcf665dcebbdf9" ] }, "content": "In your function, use `echo` to print `Ask a yes or no question:`", "hints": [ "Your function should look like this:\n```sh\nGET_FORTUNE() {\n echo Ask a yes or no question:\n}\n```", "Your `echo ${RESPONSES[$N]}` command should be at the bottom of the file" ] } ] }, { "id": "1200", "title": "Add GET_FORTUNE function call", "summary": "", "content": "", "steps": [ { "id": "1200.1", "setup": { "watchers": [ "./fortune.sh" ], "commits": [ "52cd2a8b552c14449bdfe6fd25e6b45ae597203e" ] }, "content": "Call your function by putting the name of it below where you create it. No `$` needed. Make sure the response you are printing is at the bottom of the file.", "hints": [ "Add `GET_FORTUNE` below where you create your function to call it", "Your `echo ${RESPONSES[$N]}` command should be at the bottom of the file" ] } ] }, { "id": "1210", "title": "./fortune.sh", "summary": "", "content": "", "steps": [ { "id": "1210.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "a7695da26838b007dc4e85862826be1e2bb30b1b" ] }, "content": "Run your script to make sure it's working.", "hints": [ "Type `./fortune.sh` in the terminal and press enter", "Make sure you are in the `project` folder first" ] } ] }, { "id": "1220", "title": "Add read QUESTION", "summary": "", "content": "", "steps": [ { "id": "1220.1", "setup": { "watchers": [ "./fortune.sh" ], "commits": [ "4fb51b6dec833c289bdf3ad97b5cf0433dd8bfdf" ] }, "content": "In your function after you print the sentence, use `read` to get user input into a variable named `QUESTION`.", "hints": [ "Add `read QUESTION` to your function below the `echo`", "Your function should look like this:\n```sh\nGET_FORTUNE() {\n echo Ask a yes or no question:\n read QUESTION\n}\n```", "Your `echo ${RESPONSES[$N]}` command should be at the bottom of the file" ] } ] }, { "id": "1230", "title": "./fortune.sh", "summary": "", "content": "", "steps": [ { "id": "1230.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "abcaa2b9323e45188ef1ad97487815436bc9db3a" ] }, "content": "Run the script again to test it out. Enter a question when it asks.", "hints": [ "Type `./fortune.sh` in the terminal and press enter", "Make sure you are in the `project` folder first" ] } ] }, { "id": "1240", "title": "help", "summary": "", "content": "", "steps": [ { "id": "1240.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "ef067d88fac584fef91546a9edf43371ff42d54d" ] }, "content": "I want to make sure the input is a question. You are going to add a loop that asks for input until the input ends with a question mark. View the `help` menu to see if you can find an appropriate loop.", "hints": [ "Type `help` in the terminal and press enter" ] } ] }, { "id": "1250", "title": "help until", "summary": "", "content": "", "steps": [ { "id": "1250.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "40ae7e8e1aaee1569d7c3a58a7d258b121a4ed37" ] }, "content": "View more about that `until` command. That might be the one to use here.", "hints": [ "Use `help ` to view more about a command", "Type `help until` in the terminal and press enter" ] } ] }, { "id": "1260", "title": "Add until loop", "summary": "", "content": "", "steps": [ { "id": "1260.1", "setup": { "watchers": [ "./fortune.sh" ], "commits": [ "e0c642d4efe1ec69189162007e2bb73ea0027ef1" ] }, "content": "The `until` loop is very similar to the `while` loop you used. It will execute the loop until a condition is met. Here's an example:\n\n```sh\nuntil [[ CONDITION ]]\ndo\n STATEMENTS\ndone\n```\n\nAdd an `until` loop below your function. Use the double brackets to check if `QUESTION` is equal to `test?`. Move the `GET_FORTUNE` function call to the statements area of the loop. It should run the function until you input `test?` as the question.", "hints": [ "View the `help [[` or `help test` menu to see if you can find the operator to use", "You want the `==` operator", "The condition should look like this: `[[ $QUESTION == test? ]]`", "Your `until` loop should look like this:\n```sh\nuntil [[ $QUESTION == test? ]]\ndo\n GET_FORTUNE\ndone\n```", "You should only call the `GET_FORTUNE` function once", "Your `echo ${RESPONSES[$N]}` command should be at the bottom of the file" ] } ] }, { "id": "1270", "title": "./fortune.sh", "summary": "", "content": "", "steps": [ { "id": "1270.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "3450bdac3e3f4298714e1e1515a2e87ccd117fed" ] }, "content": "Run the script and enter something other than `test?`. Then enter `test?` after it asks for a question the second time.", "hints": [ "Type `./fortune.sh` in the terminal and press enter", "Make sure you are in the `project` folder first" ] } ] }, { "id": "1280", "title": "help [[ expression ]]", "summary": "", "content": "", "steps": [ { "id": "1280.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "814637db4fce7bf27982fbcdd15716e22cf0315a" ] }, "content": "View that `help [[ expression ]]` menu again. You need to find out how to test if the input ends with a question mark (`?`).", "hints": [ "Type `help [[` or `help [[ expression ]]` in the terminal and press enter" ] } ] }, { "id": "1290", "title": "[[ hello == hello ]]; echo $?", "summary": "", "content": "", "steps": [ { "id": "1290.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "8746c43c0f46fc59342bbf0be0269733a60fab78" ] }, "content": "Let's play with these again. You can test if two strings are the same with `==`. In the terminal, use the `[[ ... ]]; echo $?` syntax you used before to test if `hello` is equal to `hello`.", "hints": [ "Be sure to use the `==` operator", "Type `[[ hello == hello ]]; echo $?` in the terminal and press enter" ] } ] }, { "id": "1300", "title": "[[ hello == world ]]; echo $?", "summary": "", "content": "", "steps": [ { "id": "1300.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "7faeea77db51b79188d7d586ad3d52d349607990" ] }, "content": "Exit status of `0`, it was true. Using the same syntax, test if `hello` is equal to `world`.", "hints": [ "Use the `[[ ... ]]; echo $?` syntax", "Be sure to use the `==` operator", "Type `[[ hello == world ]]; echo $?` in the terminal and press enter" ] } ] }, { "id": "1310", "title": "[[ hello =~ el ]]; echo $?", "summary": "", "content": "", "steps": [ { "id": "1310.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "3429f935110a1002d9ef8f11c55c0deda299eb6f" ] }, "content": "False. An important operator in that menu is `=~`. It allows for pattern matching. Using the same syntax but with this operator, check if `hello` contains the pattern `el`.", "hints": [ "Use the `[[ ... ]]; echo $?` syntax", "Use the `=~` operator with it", "Type `[[ hello =~ el ]]; echo $?` in the terminal and press enter" ] } ] }, { "id": "1320", "title": "[[ \"hello world\" =~ \"lo wor\" ]]; echo $?", "summary": "", "content": "", "steps": [ { "id": "1320.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "2d2ca6865b121e33c9c1b7a1435a4fb8d72b95bb" ] }, "content": "True. The condition was checking for `el` within the word `hello`. Using the same syntax, check if `hello world` contains the pattern `lo wor`. You will need to put them both in quotes so it recognizes the spaces.", "hints": [ "Use the `[[ ... ]]; echo $?` syntax", "Use the `=~` operator with it", "Type `[[ \"hello world\" =~ \"lo wor\" ]]; echo $?` in the terminal and press enter" ] } ] }, { "id": "1330", "title": "[[ \"hello world\" =~ ^h ]]; echo $?", "summary": "", "content": "", "steps": [ { "id": "1330.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "2e9053f4e9191f5cf2721ee4aea2bb806f6c69ba" ] }, "content": "Your patterns have been checking for literal matches, `el` and `lo wor`. You can use regular expression characters as well, but you can't put the pattern in quotes when you do. Using the same syntax, check if `hello world` starts with an `h` by using `^h` as the pattern.", "hints": [ "Make sure not to use quotes around the pattern when using regex characters it", "Type `[[ \"hello world\" =~ ^h ]]; echo $?` in the terminal" ] } ] }, { "id": "1340", "title": "[[ \"hello world\" =~ ^h.+d$ ]]; echo $?", "summary": "", "content": "", "steps": [ { "id": "1340.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "bde1437e6868a46778920620a6ee33ff520c3106" ] }, "content": "Do it again, but use `^h.+d$` as the pattern to see if the string starts with an `h`, has at least one character after it, and ends with a `d`.", "hints": [ "Use the `[[ ... ]]; echo $?` syntax again", "Check if `hello world` contains the suggested pattern", "Make sure not to use quotes around the pattern when using regex characters it", "Type `[[ \"hello world\" =~ ^h.+d$ ]]; echo $?` in the terminal" ] } ] }, { "id": "1350", "title": "VAR=\"hello world\"", "summary": "", "content": "", "steps": [ { "id": "1350.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "ea5ee7cb0e002a6fe36f9ee53eaf7164f9208041" ] }, "content": "In the terminal, create a variable named `VAR` that equals `hello world`.", "hints": [ "Type `VAR=\"hello world\"` in the terminal" ] } ] }, { "id": "1360", "title": "echo $VAR", "summary": "", "content": "", "steps": [ { "id": "1360.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "28314e08ace3ee3026f27d3e17fb1262947f9a27" ] }, "content": "Use `echo` to print the variable you just created.", "hints": [ "Type `echo $VAR` in the terminal" ] } ] }, { "id": "1370", "title": "[[ $VAR == \"hello world\" ]]; echo $?", "summary": "", "content": "", "steps": [ { "id": "1370.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "dd275d39c5579a25a2738622840b491d3c5593b4" ] }, "content": "Using the `[[ ... ]]; echo $?` syntax, check if your variable is equal to `hello world`.", "hints": [ "Check the `help [[` menu to find the operator to use", "It's the `==` operator", "You want to check if `$VAR == \"hello world\"`", "Type `[[ $VAR == \"hello world\" ]]; echo $?` in the terminal" ] } ] }, { "id": "1380", "title": "[[ $VAR =~ \\?$ ]; echo $?", "summary": "", "content": "", "steps": [ { "id": "1380.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "1bd60833f62a63ab0d681e7a56ce50ec2f284e23" ] }, "content": "Using the same syntax, check if your variable ends with `?` by using the pattern `\\?$`.", "hints": [ "Be sure to use the pattern matching operator", "It's the `=~` operator", "You want to check if `$VAR =~ \\?$`", "Type `[[ $VAR =~ \\?$ ]]; echo $?` in the terminal" ] } ] }, { "id": "1385", "title": "[[ test? =~ \\?$ ]; echo $?", "summary": "", "content": "", "steps": [ { "id": "1385.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "5d2bda9231186f953db932c12ed82b28524ba43b" ] }, "content": "It doesn't end with `?`. Just to make sure I don't have the pattern wrong, check if `test?` ends with `?`.", "hints": [ "Use the same `[[ ... ]]; echo $?` syntax you have been using", "Use the `\\?$` pattern to see if a string ends with `?`", "Make sure you're using the pattern matching operator `=~`", "You want to check if `test? =~ \\?$`", "Type `[[ test? =~ \\?$ ]]; echo $?` in the terminal" ] } ] }, { "id": "1390", "title": "Change until condition", "summary": "", "content": "", "steps": [ { "id": "1390.1", "setup": { "watchers": [ "./fortune.sh" ], "commits": [ "cb5142cd8434d3e23aeecb4f7532a54744a5a550" ] }, "content": "I think that will work. Back in your script, change the `until` condition to see if your variable ends with `?`.", "hints": [ "Use the pattern matching operator with `\\?$`", "It's the `=~` operator", "Your condition should look like this: `[[ $QUESTION =~ \\?$ ]]`", "Make sure there's spaces inside the brackets and around the operator" ] } ] }, { "id": "1400", "title": "./fortune.sh", "summary": "", "content": "", "steps": [ { "id": "1400.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "494562adfed9aabb9c24778b2d2b47f109d579ae" ] }, "content": "Run the script and input something that doesn't end with `?` the first time, then something that does the second.", "hints": [ "Type `./fortune.sh` in the terminal and press enter", "Make sure you are in the `project` folder first" ] } ] }, { "id": "1410", "title": "Add if to GET_FORTUNE", "summary": "", "content": "", "steps": [ { "id": "1410.1", "setup": { "watchers": [ "./fortune.sh" ], "commits": [ "aeae05477a13c14adeb951b76770cfb887ed19a1" ] }, "content": "I know that it asks the same thing if the input isn't what you want. You should let users know that it needs to end with `?`. Add an `if` condition in your **function** that checks `if [[ ! $1 ]]`. Put the existing `echo` statement in the `then` area and make sure the existing `read` is below the whole `if` condition.", "hints": [ "Here's an example:\n```sh\nif [[ CONDITION ]]\nthen\n STATEMENTS\nfi\n\nread QUESTION\n```", "Your function should look like this:\n```sh\nfunction GET_FORTUNE() {\n if [[ ! $1 ]]\n then\n echo Ask a yes or no question:\n fi\n\n read QUESTION\n}\n```" ] } ] }, { "id": "1412", "title": "Add else to if [[ ! $1 ]]", "summary": "", "content": "", "steps": [ { "id": "1412.1", "setup": { "watchers": [ "./fortune.sh" ], "commits": [ "380bf3b8be3bd0772f7f12ad9a2045d27816b178" ] }, "content": "You can pass arguments to functions like you did with your script. This condition will check if one isn't passed and print the sentence. Add an `else` to your `if`. Use `echo` to print `Try again. Make sure it ends with a question mark:` if the condition fails.", "hints": [ "Here's an example:\n```sh\nif [[ CONDITION ]]\nthen\n STATEMENTS\nelse\n STATEMENTS\nfi\n```", "Your `if` condition should look like this:\n```sh\nif [[ ! $1 ]]\nthen\n echo Ask a yes or no question:\nelse\n echo Try again. Make sure it ends with a question mark:\nfi\n```" ] } ] }, { "id": "1413", "title": "Add argument to function call", "summary": "", "content": "", "steps": [ { "id": "1413.1", "setup": { "watchers": [ "./fortune.sh" ], "commits": [ "4a438f7dfb9076a664895420c34919370910ea6f" ] }, "content": "Now, your function will print one thing if you pass it any argument, and something else if not. In the `until` loop, add `again` as an argument to where you call the function.", "hints": [ "Here's an example: `FUNCTION_NAME argument`", "Your function call should look like this: `GET_FORTUNE again`", "Your `until` loop should look like this:\n```sh\nuntil [[ $QUESTION =~ \\?$ ]]\ndo\n GET_FORTUNE again\ndone\n```" ] } ] }, { "id": "1416", "title": "Add Initial function call", "summary": "", "content": "", "steps": [ { "id": "1416.1", "setup": { "watchers": [ "./fortune.sh" ], "commits": [ "324fcb85a3d1ee627f5e3f6e671a748df364e837" ] }, "content": "Now, each time the function is called in the `until` loop, it will pass `again` as an argument and print the `Try again...` sentence. Before your `until` loop, call the function without an argument so the first time it runs, it prints the initial sentence.", "hints": [ "Add `GET_FORTUNE` before the `until` loop" ] } ] }, { "id": "1420", "title": "./fortune.sh", "summary": "", "content": "", "steps": [ { "id": "1420.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "9e9241861d3594cd8d9e9fe71b740a423471c0c8" ] }, "content": "Run the script and enter something without a question mark when it asks the first time. Use a question mark the second time.", "hints": [ "Type `./fortune.sh` in the terminal and press enter", "Make sure you are in the `project` folder first" ] } ] }, { "id": "1425", "title": "Add line break in front of response", "summary": "", "content": "", "steps": [ { "id": "1425.1", "setup": { "watchers": [ "./fortune.sh" ], "commits": [ "d2c548715c431f43692b6c78e38795a7fdf0335b" ] }, "content": "Awesome. One last thing. Add an empty line in front of where you print the response.", "hints": [ "Change the existing `echo ${RESPONSES[$N]}` line", "Use the `-e` flag and the new line (`\\n`) character with the `echo` statement", "Make sure to use quotes so it prints the new line", "Run the script and see if it's working", "The suggested command should look like this: `echo -e \"\\n${RESPONSES[$N]}\"`" ] } ] }, { "id": "1428", "title": "./fortune.sh", "summary": "", "content": "", "steps": [ { "id": "1428.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "efefa327a027bae2b7f4b8cbcf5b9fa45b5693c9" ] }, "content": "Run the script one more time to see if you like the output.", "hints": [ "Type `./fortune.sh` in the terminal and press enter", "Make sure you are in the `project` folder first" ] } ] }, { "id": "1430", "title": "touch five.sh", "summary": "", "content": "", "steps": [ { "id": "1430.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "781ce90e8da4e84d244b6405cfa8b1bff0d735c0" ] }, "content": "Excellent. One last program to make. Use `touch` to create a new file named `five.sh` in the same folder as the others.", "hints": [ "Type `touch five.sh` in the terminal and press enter", "Make sure you are in the `project` folder first" ] } ] }, { "id": "1440", "title": "chmod +x five.sh", "summary": "", "content": "", "steps": [ { "id": "1440.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "b3cd240d5c0e890b4f7d0376bfacec6653497ef4" ] }, "content": "Give your file executable permissions.", "hints": [ "Use the `chmod` command with the `+x` flag", "Here's an example `chmod `", "You previously used `chmod +x fortune.sh`", "Type `chmod +x five.sh` in the terminal and press enter" ] } ] }, { "id": "1450", "title": "Add shebang", "summary": "", "content": "", "steps": [ { "id": "1450.1", "setup": { "watchers": [ "./five.sh" ], "commits": [ "600d935f73ca8d6eade088cb30cc3c51bd09eb70" ] }, "content": "Add a `shebang` to the new script that uses `bash` like the others.", "hints": [ "A `shebang` looks like this: `#!`", "Enter `which bash` in the terminal to see the path to `bash`", "Look at the `shebang` in one of your other scripts to get the syntax", "It should look like this: `#!/bin/bash`", "Add `#!/bin/bash` at the top of your `five.sh` file" ] } ] }, { "id": "1460", "title": "Add comment", "summary": "", "content": "", "steps": [ { "id": "1460.1", "setup": { "watchers": [ "./five.sh" ], "commits": [ "ed12144637452be8a7607aa9620e08889eb3e44c" ] }, "content": "Add a comment below the `shebang` that says, `Program to run my other four programs`", "hints": [ "Comments look like this: `# `", "Add `# Program to run my other four programs` below the `shebang`", "Capitalization matters" ] } ] }, { "id": "1470", "title": "Add ./questionnaire.sh", "summary": "", "content": "", "steps": [ { "id": "1470.1", "setup": { "watchers": [ "./five.sh" ], "commits": [ "596f431aa5f3db7610463e7a146a98a0224e6afe" ] }, "content": "This program will run all the programs you made so far consecutively. Add the command to run the `questionnaire.sh` file.", "hints": [ "The command should look like how you would execute the file in the terminal", "Add `./questionnaire.sh` to the `five.sh` file" ] } ] }, { "id": "1480", "title": "./five", "summary": "", "content": "", "steps": [ { "id": "1480.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "35cc3cea0ca8e5d30e2b5c75e8fa90dea42c4377" ] }, "content": "Run the file to see if it works. Enter input when it asks.", "hints": [ "Type `./five.sh` in the terminal and press enter", "Make sure you are in the `project` folder first" ] } ] }, { "id": "1490", "title": "Add the rest of the scripts", "summary": "", "content": "", "steps": [ { "id": "1490.1", "setup": { "watchers": [ "./five.sh" ], "commits": [ "92850450c6ec7cbdb5c17f47d7bc4ce8e372afa3" ] }, "content": "Add commands to run the rest of your scripts in the file. They should be in this order: `questionnaire`, `countdown`, `bingo`, and `fortune`. Don't forget that your `countdown.sh` file needs an argument, so put a `3` next to it.", "hints": [ "Your `five.sh` file should have these commands:\n```sh\n./questionnaire.sh\n./countdown.sh 3\n./bingo.sh\n./fortune.sh\n```" ] } ] }, { "id": "1500", "title": "Clear", "summary": "", "content": "", "steps": [ { "id": "1500.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "ab932636cb400bcae42284cd965bf0293eea4f5a" ] }, "content": "Okay, use `clear` to empty out what's in the terminal before the big moment.", "hints": [ "Type `clear` in the terminal" ] } ] }, { "id": "1510", "title": "./five", "summary": "", "content": "", "steps": [ { "id": "1510.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "000f62662ab29bb322e4c16f8d296b0309c969fe" ] }, "content": "Run the script and enter input when it asks.", "hints": [ "Type `./five.sh` in the terminal and press enter", "Make sure you are in the `project` folder first" ] } ] }, { "id": "1520", "title": "help", "summary": "", "content": "", "steps": [ { "id": "1520.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "0020e8e0262b988a15ca445fcd5a256b9a23c6fb" ] }, "content": "Cool. I think all the scripts are done. View the `help` menu again I want to explore one more thing.", "hints": [ "Type `help` in the terminal and press enter" ] } ] }, { "id": "1530", "title": "help type", "summary": "", "content": "", "steps": [ { "id": "1530.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "e497707bc47bb00839f084976de8a931080ef111" ] }, "content": "View more about that `type` command.", "hints": [ "Use `help ` to find out more about a command", "Type `help type` in the terminal and press enter" ] } ] }, { "id": "1540", "title": "type echo", "summary": "", "content": "", "steps": [ { "id": "1540.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "85aab97c0f3a73d1b01c80c97a39580afaf2e49c" ] }, "content": "It says you can view the type of a command with `type `. Just for fun, lets take a look at the type of a few different commands. View the type of `echo`.", "hints": [ "Type `type echo` in the terminal and press enter" ] } ] }, { "id": "1550", "title": "type read", "summary": "", "content": "", "steps": [ { "id": "1550.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "2042a1384041e64f140e8239a31a386ac965186d" ] }, "content": "View the type of the `read` command.", "hints": [ "Type `type read` in the terminal and press enter" ] } ] }, { "id": "1560", "title": "type if", "summary": "", "content": "", "steps": [ { "id": "1560.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "21c228b482c27b245638be8bfaaad8c5b63d9a63" ] }, "content": "View the type of `if`", "hints": [ "Type `type if` in the terminal and press enter" ] } ] }, { "id": "1570", "title": "type then", "summary": "", "content": "", "steps": [ { "id": "1570.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "33d983b0b632042e55d82b514b234fbc2b4e4c2b" ] }, "content": "View the type of `then`", "hints": [ "Type `type then` in the terminal and press enter" ] } ] }, { "id": "1580", "title": "type bash", "summary": "", "content": "", "steps": [ { "id": "1580.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "a638a83758e348d9c9794d1963c637ec219306f3" ] }, "content": "Those were all from the `help` menu and described as a `shell builtin` or `shell keyword`. View the type of `bash`", "hints": [ "Type `type bash` in the terminal and press enter" ] } ] }, { "id": "1590", "title": "type psql", "summary": "", "content": "", "steps": [ { "id": "1590.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "504b22b8212d539520fed73bd00ee28925ac1f8e" ] }, "content": "That's the location of the `bash` command. View the type of `psql`.", "hints": [ "Type `type psql` in the terminal and press enter" ] } ] }, { "id": "1600", "title": "type ./five.sh", "summary": "", "content": "", "steps": [ { "id": "1600.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "ece9f053a5f0f0f859b848d6d38b99d9c100841a" ] }, "content": "It's showing the location of the commands. View the type of your `./five.sh` file.", "hints": [ "Type `type ./five.sh` in the terminal and press enter" ] } ] }, { "id": "1610", "title": "exit", "summary": "", "content": "", "steps": [ { "id": "1610.1", "setup": { "watchers": [ "../.bash_history" ], "commits": [ "876baa475f70b3df2a4df9fbb87bec857b72ec4d" ] }, "content": "Last step, close the terminal with the `exit` command. Thanks and happy coding!", "hints": [ "Type `exit` in the terminal and press enter" ] } ] } ] }