Bird
0
0

How can you combine single and double quotes to assign the string She said, "It's fine" literally to a variable?

hard🚀 Application Q9 of 15
Bash Scripting - Quoting and Expansion
How can you combine single and double quotes to assign the string She said, "It's fine" literally to a variable?
Atext="She said, \"It's fine\""
Btext="She said, 'It's fine'"
Ctext='She said, "It'\''s fine"'
D'"enif s''\'tI" ,dias ehS'=txet
Step-by-Step Solution
Solution:
  1. Step 1: Understand mixing quotes

    Double quotes allow variable expansion and escaping double quotes inside. Single quotes prevent expansion but can't contain unescaped single quotes.
  2. Step 2: Analyze options

    text="She said, \"It's fine\"" uses double quotes outside and escapes inner double quotes, preserving the literal string including single quote. Options C and D have syntax errors due to improper quote closing. text="She said, 'It's fine'" uses single quotes inside double quotes but does not match the required double quotes.
  3. Final Answer:

    text="She said, \"It's fine\"" -> Option A
  4. Quick Check:

    Use double quotes with escaped inner double quotes = text="She said, \"It's fine\"" [OK]
Quick Trick: Use double quotes outside and escape inner double quotes [OK]
Common Mistakes:
MISTAKES
  • Incorrectly closing quotes
  • Not escaping inner quotes properly
  • Confusing single and double quote rules

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bash Scripting Quizzes