Bird
0
0

Which of the following is the correct syntax to print the value of variable count followed by the word "items"?

easy📝 Syntax Q3 of 15
Bash Scripting - Variables
Which of the following is the correct syntax to print the value of variable count followed by the word "items"?
Aecho $countitems
Becho ${count}items
Cecho $count items
Decho ${count items}
Step-by-Step Solution
Solution:
  1. Step 1: Identify variable and text concatenation

    To print variable value followed immediately by text, use braces to separate variable name.
  2. Step 2: Analyze each option

    A merges variable name and text incorrectly; B correctly uses braces; C prints variable then space then text; D is invalid syntax.
  3. Final Answer:

    echo ${count}items -> Option B
  4. Quick Check:

    Braces separate variable name = B [OK]
Quick Trick: Use ${var}text to join variable and text without spaces [OK]
Common Mistakes:
MISTAKES
  • Forgetting braces when concatenating
  • Adding spaces inside braces
  • Using invalid brace syntax

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bash Scripting Quizzes