Bird
0
0

How do you assign the string Hello World to a variable msg preserving the space in bash?

hard🚀 Application Q9 of 15
Bash Scripting - Variables
How do you assign the string Hello World to a variable msg preserving the space in bash?
Amsg='Hello World'
Bmsg=Hello World
Cmsg=Hello_World
Dmsg= "Hello World"
Step-by-Step Solution
Solution:
  1. Step 1: Understand how to assign strings with spaces

    Strings with spaces must be quoted to be assigned correctly.
  2. Step 2: Check for correct quoting and no spaces around =

    msg='Hello World' uses single quotes with no spaces around =, which is correct.
  3. Final Answer:

    msg='Hello World' -> Option A
  4. Quick Check:

    Quote strings with spaces and no spaces around = [OK]
Quick Trick: Quote strings with spaces; no spaces around = [OK]
Common Mistakes:
MISTAKES
  • Not quoting strings with spaces
  • Adding spaces around =
  • Using double quotes with spaces incorrectly

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bash Scripting Quizzes