Courseiva

XK0-006 Automation, Orchestration, and Scripting Practice Question

In a Bash script, what is the difference between single quotes and double quotes?

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

✓

Single quotes prevent variable expansion; double quotes allow it.

Single quotes preserve the literal value of each character, while double quotes allow variable expansion and command substitution.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ✗

    Both behave the same.

    Why it's wrong here

    Single quotes suppress variable expansion, command substitution and backslash escaping, while double quotes permit all three, so the quoting styles differ materially. Treating them as identical is tempting when a script contains only literal text, where either quoting style produces the same output.

  • ✗

    Single quotes allow variable expansion; double quotes do not.

    Why it's wrong here

    Variable expansion occurs inside double quotes, not single quotes; single quotes treat the dollar sign literally. The reversed claim is tempting because single quotes do preserve text verbatim, which sounds like expansion until you test echo with a defined variable.

  • ✗

    Double quotes prevent all substitutions; single quotes allow command substitution.

    Why it's wrong here

    The behaviour is reversed: double quotes allow variable and command substitution, while single quotes suppress every substitution. This inversion is tempting because double quotes do protect against word splitting and globbing, which can be mistaken for preventing substitution entirely.

  • ✓

    Single quotes prevent variable expansion; double quotes allow it.

    Why this is correct

    Within single quotes, Bash treats every character literally, so $VAR stays unexpanded; double quotes permit parameter and command substitution while still suppressing word splitting and globbing. This satisfies the stem's request for the precise difference in expansion behaviour between the two quoting styles.

About these practice questions

This XK0-006 question is part of Courseiva's 781-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

This XK0-006 practice question is part of Courseiva's free CompTIA certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the XK0-006 exam.