Bird
0
0

What happens if you use a variable without quotes in a command and the variable contains a filename with spaces?

easy🧠 Conceptual Q2 of 15
Bash Scripting - Quoting and Expansion
What happens if you use a variable without quotes in a command and the variable contains a filename with spaces?
AThe command converts spaces to underscores
BThe command ignores the filename
CThe command automatically adds quotes
DThe command treats the filename as multiple separate arguments
Step-by-Step Solution
Solution:
  1. Step 1: Recognize how bash parses arguments

    Bash splits unquoted variables by spaces, so a filename with spaces becomes multiple arguments.
  2. Step 2: Effect on command behavior

    The command receives wrong arguments, causing errors or unexpected behavior.
  3. Final Answer:

    The command treats the filename as multiple separate arguments -> Option D
  4. Quick Check:

    Unquoted variables split arguments = D [OK]
Quick Trick: Quote filenames to keep them as one argument [OK]
Common Mistakes:
MISTAKES
  • Not quoting filenames with spaces
  • Assuming shell auto-quotes
  • Using single quotes which prevent expansion

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bash Scripting Quizzes