Bird
0
0

What will be the output when running ./welcome.sh Bob if welcome.sh contains:

medium📝 Command Output Q4 of 15
Bash Scripting - Basics
What will be the output when running ./welcome.sh Bob if welcome.sh contains:
#!/bin/bash
echo "Welcome, $1!"
AWelcome, !
BWelcome, $1!
CWelcome, Bob!
DError: Missing argument
Step-by-Step Solution
Solution:
  1. Step 1: Understand positional parameters

    $1 represents the first argument passed to the script.
  2. Step 2: Substitute argument

    Running ./welcome.sh Bob passes "Bob" as $1.
  3. Final Answer:

    Welcome, Bob! -> Option C
  4. Quick Check:

    Positional parameters replace $1 with first argument [OK]
Quick Trick: Use $1 to access first argument in script [OK]
Common Mistakes:
MISTAKES
  • Not passing any argument so $1 is empty
  • Using single quotes which prevent variable expansion
  • Confusing $1 with other variables

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bash Scripting Quizzes