Bird
0
0

Which of the following correctly escapes a dollar sign ($) in a bash echo command?

easy🧠 Conceptual Q2 of 15
Bash Scripting - Quoting and Expansion
Which of the following correctly escapes a dollar sign ($) in a bash echo command?
Aecho \100
Becho $100
Cecho \$100
Decho $\100
Step-by-Step Solution
Solution:
  1. Step 1: Identify how to escape $ in bash

    The dollar sign is special for variables, so to print it literally, prefix with backslash: \$
  2. Step 2: Check each option

    echo \$100 uses \$ correctly; B treats $100 as variable, C escapes wrong character, D mixes incorrectly.
  3. Final Answer:

    echo \$100 -> Option C
  4. Quick Check:

    Escape $ sign = A [OK]
Quick Trick: Escape $ with backslash to print it literally [OK]
Common Mistakes:
MISTAKES
  • Not escaping $ prints variable value
  • Escaping wrong character
  • Mixing backslash and $ incorrectly

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bash Scripting Quizzes