That's a great question! In Shell scripting, variables act like containers that store information.
For our "Fruit Basket," you will use variables to store the quantity of each fruit. Here is how it will look in your script:
1. Defining the Variables
Instead of just remembering numbers, you assign them to names. For example:
apples=5
oranges=10
apples: This is the variable name.=: This assigns the value to the name (note: there are no spaces around the=in Bash).5: This is the value stored inside.
2. Accessing the Variables
When you want to use those numbers later (for example, to add them together), you put a dollar sign ($) before the name:
echo "I have $apples apples."
3. Using them for Arithmetic
In this lab, you will use these variables to perform calculations. For example, to find the total:
total=$((apples + oranges))
The notation $(( ... )) tells Bash to perform a mathematical operation using the values stored in your fruit variables.
Ready to try it? After you've added the #!/bin/bash line as instructed in the current step, the next parts of the lab will guide you through typing these exact types of commands