Bird
0
0

Which of the following is the correct syntax to create a variable named name with the value John in Bash?

easy📝 Syntax Q3 of 15
Linux CLI - Linux Basics and Terminal
Which of the following is the correct syntax to create a variable named name with the value John in Bash?
Aname = John
Bset name John
Cname == John
Dname=John
Step-by-Step Solution
Solution:
  1. Step 1: Recall Bash variable assignment rules

    In Bash, variable assignment must have no spaces around the equal sign. So name=John is correct.
  2. Step 2: Check other options for syntax errors

    name = John has spaces, which is invalid. name == John is a comparison, not assignment. set name John is not standard Bash syntax for variable assignment.
  3. Final Answer:

    name=John -> Option D
  4. Quick Check:

    Variable assignment syntax = name=John [OK]
Quick Trick: No spaces around = when assigning variables in Bash [OK]
Common Mistakes:
  • Adding spaces around =
  • Using == for assignment
  • Using set incorrectly

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Linux CLI Quizzes