What happens with variable name "PRICE" vs "price"?

QuestionsQuestions8 SkillsProDec, 21 2025
079

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 $price when 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

0 Comments

no data
Be the first to share your comment!