Bird
0
0

Find the error in this shell script:

medium📝 Debug Q7 of 15
Bash Scripting - Basics
Find the error in this shell script:
#!/bin/bash
name=John
 echo "Hello, $name!"
AExtra space before echo command
BNo error, script runs fine
CVariable assignment missing quotes
DMissing shebang line
Step-by-Step Solution
Solution:
  1. Step 1: Check variable assignment syntax

    Assigning name=John without quotes is valid since John has no spaces.
  2. Step 2: Check echo command and spacing

    Extra space before echo is allowed; shebang line is present.
  3. Final Answer:

    No error, script runs fine -> Option B
  4. Quick Check:

    Valid syntax means script runs without errors [OK]
Quick Trick: Spaces before commands are allowed but not recommended [OK]
Common Mistakes:
MISTAKES
  • Thinking quotes are always required
  • Assuming spaces cause errors
  • Missing shebang line confusion

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bash Scripting Quizzes