Bird
0
0

You want to store a user's full name with spaces in a variable fullname and then print it. Which script correctly does this?

hard🚀 Application Q15 of 15
Bash Scripting - Variables
You want to store a user's full name with spaces in a variable fullname and then print it. Which script correctly does this?
Afullname=John Doe echo $fullname
Bfullname='John Doe' echo fullname
Cfullname="John Doe" echo $fullname
Dfullname=John_Doe echo $fullname
Step-by-Step Solution
Solution:
  1. Step 1: Assign string with spaces to variable

    Strings with spaces must be quoted to be assigned correctly in bash.
  2. Step 2: Print the variable value

    Use echo $fullname to print the stored string value.
  3. Final Answer:

    fullname="John Doe" echo $fullname -> Option C
  4. Quick Check:

    Quote strings with spaces and use $ to print [OK]
Quick Trick: Quote strings with spaces; use $ to print variable [OK]
Common Mistakes:
MISTAKES
  • Not quoting strings with spaces causes errors
  • Printing variable name without $ prints literal text
  • Using underscores instead of spaces changes the string

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bash Scripting Quizzes