That is a great question! In Shell scripting, variable names are case-sensitive.
This means that PRICE and price are treated as two completely different variables.
Example
If you were to add this to your script:
PRICE=10
price=20
echo "Uppercase PRICE is: $PRICE"
echo "Lowercase price is: $price"
The output would show:
Uppercase PRICE is: 10
Lowercase price is: 20
Best Practices
- UPPERCASE: By convention, most Linux users use all uppercase letters for environment variables and global variables (e.g.,
PATH,USER,PRICE_PER_APPLE). - lowercase: Often used for local variables or variables within a small loop.
- Consistency: The most important thing is to be consistent so you don't accidentally try to call
$pricewhen you actually named it$PRICE, which would result in an empty value!
In your current lab, you used PRICE_PER_APPLE. If you tried to use echo $price_per_apple, the shell wouldn't find it and would likely print nothing