Bird
0
0

Which of the following is the correct way to print the value of variable name followed immediately by the string _end in bash?

easy📝 Syntax Q12 of 15
Bash Scripting - Variables
Which of the following is the correct way to print the value of variable name followed immediately by the string _end in bash?
Aecho $name_end
Becho $name _end
Cecho ${name_end}
Decho ${name}_end
Step-by-Step Solution
Solution:
  1. Step 1: Understand variable and string concatenation

    To print variable name followed by _end, we must separate the variable name from the string.
  2. Step 2: Use braces to separate variable name

    Using ${name}_end correctly prints the variable value plus the string _end. Without braces, $name_end looks for a variable named name_end.
  3. Final Answer:

    echo ${name}_end -> Option D
  4. Quick Check:

    Braces separate variable name from text = C [OK]
Quick Trick: Use braces when adding text right after variable [OK]
Common Mistakes:
MISTAKES
  • Forgetting braces and getting wrong variable
  • Adding space breaks concatenation
  • Using wrong variable name inside braces

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bash Scripting Quizzes