Bird
0
0

Identify the error in this script snippet:

medium📝 Debug Q14 of 15
Bash Scripting - Variables
Identify the error in this script snippet:
count=5
echo "Count is $count"
count = 10
echo "New count is $count"
AVariable assignment with spaces around = is invalid
BThe first echo command is incorrect
CVariable names cannot be numbers
Decho cannot print variables
Step-by-Step Solution
Solution:
  1. Step 1: Check variable assignments

    The first assignment 'count=5' is correct. The second 'count = 10' has spaces around '=', which is invalid in bash.
  2. Step 2: Understand bash syntax rules

    Spaces around '=' cause bash to treat it as a command, leading to errors.
  3. Final Answer:

    Variable assignment with spaces around = is invalid -> Option A
  4. Quick Check:

    No spaces around = in assignment = B [OK]
Quick Trick: No spaces around = in variable assignment [OK]
Common Mistakes:
MISTAKES
  • Adding spaces around = in assignments
  • Thinking echo can't print variables
  • Misunderstanding variable naming rules

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bash Scripting Quizzes