- The script prompts the user to enter their favorite color.
- It then uses a
casestatement to check if the input is a primary color (red, blue, yellow) or a secondary color (green, orange, purple). - remember (red, blue, yellow) should be accepted case-insesitive.
- The script outputs a message based on the color input.
- The script uses a for loop to iterate through the numbers 1 to 10.
- It outputs each number to the console using the echo command.
-
Always add comments to your script to explain what each section is doing. This makes it easier for others to understand your code and for you to come back to it later.
-
Use descriptive variable names that are easy to understand. This makes your code easier to read and debug.
-
Test your script with different input values to make sure it works as expected.
-
Use exit codes to indicate success or failure of your script. An exit code of 0 means success, while any other value means failure.
-
Use conditional statements like if/else and case to perform different actions based on the user's input.
-
Use loops like for and while to repeat certain actions multiple times.
-
Use sleep to pause the execution of your script for a certain amount of time.
-
Always validate user input to prevent errors or unexpected behavior.
Bash scripts related to every session of this tutorial will be stored in isolated branches named after their session name.
You can access the main code and the challenge answer key related to every session at their own branch.