Bird
0
0

What will be the output of the following bash script?

medium📝 Command Output Q4 of 15
Bash Scripting - Variables
What will be the output of the following bash script?
name=Alice
age=30
echo "$name is $age years old"
A$name is $age years old
Bname is age years old
CAlice is 30 years old
DAlice is $age years old
Step-by-Step Solution
Solution:
  1. Step 1: Understand variable assignment and usage

    Variables name and age are assigned correctly without spaces.
  2. Step 2: Check echo command with variable expansion

    Using double quotes allows variables to expand to their values.
  3. Final Answer:

    Alice is 30 years old -> Option C
  4. Quick Check:

    Variable expansion = Alice is 30 years old [OK]
Quick Trick: Use double quotes to expand variables in echo [OK]
Common Mistakes:
MISTAKES
  • Using single quotes preventing expansion
  • Spaces in assignment
  • Forgetting $ in echo

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bash Scripting Quizzes