Bird
0
0

Identify the error in this script:

medium📝 Debug Q6 of 15
Bash Scripting - Quoting and Expansion
Identify the error in this script:
filename=My Documents/file.txt
echo "$filename"
ANo error, script runs fine
Becho command missing quotes
CVariable name invalid
DVariable assignment missing quotes around value with spaces
Step-by-Step Solution
Solution:
  1. Step 1: Check variable assignment syntax

    Value contains spaces but is unquoted, causing syntax error.
  2. Step 2: Check echo command

    Echo uses quotes correctly; problem is assignment.
  3. Final Answer:

    Variable assignment missing quotes around value with spaces -> Option D
  4. Quick Check:

    Quote values with spaces in assignments = D [OK]
Quick Trick: Quote variable values with spaces during assignment [OK]
Common Mistakes:
MISTAKES
  • Not quoting values with spaces
  • Assuming echo quotes fix assignment errors
  • Using invalid variable names

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bash Scripting Quizzes