Bird
0
0

You want to create a bash script that prints the exact string: Path is C:\Program Files\App. Which command inside the script will produce this output correctly?

hard🚀 Application Q15 of 15
Bash Scripting - Quoting and Expansion
You want to create a bash script that prints the exact string: Path is C:\Program Files\App. Which command inside the script will produce this output correctly?
Aecho Path is C:\\Program Files\\App
Becho 'Path is C:\Program Files\App'
Cecho Path is C:\Program Files\App
Decho "Path is C:\\Program Files\\App"
Step-by-Step Solution
Solution:
  1. Step 1: Understand escaping backslashes in bash strings

    Backslash is special, so to print one backslash inside double quotes, use two backslashes \\.
  2. Step 2: Analyze each option's output

    echo "Path is C:\\Program Files\\App" doubles backslashes inside double quotes, printing correctly. echo 'Path is C:\Program Files\App' uses single quotes but backslash is literal, so output misses doubling. echo Path is C:\Program Files\App and D do not escape spaces or backslashes properly.
  3. Final Answer:

    echo "Path is C:\\Program Files\\App" -> Option D
  4. Quick Check:

    Double backslash inside quotes prints one backslash = A [OK]
Quick Trick: Double backslash inside "" prints one backslash [OK]
Common Mistakes:
MISTAKES
  • Using single backslash inside double quotes
  • Not escaping backslash at all
  • Confusing single and double quotes effects

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bash Scripting Quizzes