Bird
0
0

Identify the error in this script snippet:

medium📝 Debug Q6 of 15
Bash Scripting - Variables
Identify the error in this script snippet:
user = "Bob"
echo $user
ASpaces around '=' cause an error in variable assignment
BMissing dollar sign before variable name in echo
CQuotes around Bob are not allowed
DVariable names cannot be lowercase
Step-by-Step Solution
Solution:
  1. Step 1: Check variable assignment syntax

    Bash does not allow spaces around '=' in assignments.
  2. Step 2: Analyze the snippet

    user = "Bob" has spaces, causing an error; correct is user="Bob".
  3. Final Answer:

    Spaces around '=' cause an error in variable assignment -> Option A
  4. Quick Check:

    Remove spaces around '=' to fix assignment [OK]
Quick Trick: No spaces around '=' in bash assignments [OK]
Common Mistakes:
MISTAKES
  • Adding spaces around '=' in assignments
  • Forgetting to use $ when referencing variables
  • Misusing quotes in variable values

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bash Scripting Quizzes