Bird
0
0

Identify the error in this bash command:

medium📝 Debug Q6 of 15
Bash Scripting - Quoting and Expansion
Identify the error in this bash command:

cd ~ /documents
ATilde cannot be used with cd command
BMissing quotes around path
CSpace between ~ and / causes tilde expansion failure
DNo error, command works fine
Step-by-Step Solution
Solution:
  1. Step 1: Analyze the command syntax

    The space between ~ and /documents separates arguments, so ~ expands alone, and /documents is separate.
  2. Step 2: Understand effect of space

    This causes cd to receive two arguments, which is invalid and causes an error.
  3. Final Answer:

    Space between ~ and / causes tilde expansion failure -> Option C
  4. Quick Check:

    No spaces between ~ and path [OK]
Quick Trick: No spaces between ~ and path for correct expansion [OK]
Common Mistakes:
MISTAKES
  • Adding space between ~ and directory
  • Thinking quotes are always needed
  • Assuming tilde can't be used with cd

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bash Scripting Quizzes