Bird
0
0

Given the script hello.sh with content:

medium📝 Command Output Q13 of 15
Bash Scripting - Basics
Given the script hello.sh with content:
#!/bin/bash
echo "Hello, $1!"

What is the output of ./hello.sh World?
AHello, $1!
BHello, World!
CHello, !
DSyntax error
Step-by-Step Solution
Solution:
  1. Step 1: Understand script parameter usage

    The script uses $1 which is the first argument passed to the script. Here, World is passed as the first argument.
  2. Step 2: Predict output after substitution

    The echo command prints "Hello, World!" by replacing $1 with the argument.
  3. Final Answer:

    Hello, World! -> Option B
  4. Quick Check:

    Argument $1 replaced by 'World' = A [OK]
Quick Trick: Arguments like $1 print passed values in scripts [OK]
Common Mistakes:
MISTAKES
  • Printing literal $1 instead of argument
  • Missing argument causing empty output
  • Assuming syntax error due to shebang

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bash Scripting Quizzes