Bird
0
0

In a bash function, what does $2 represent?

easy🧠 Conceptual Q1 of 15
Bash Scripting - Functions
In a bash function, what does $2 represent?
AThe name of the function
BThe second argument passed to the function
CThe total number of arguments
DThe first argument passed to the function
Step-by-Step Solution
Solution:
  1. Step 1: Understand positional parameters in bash functions

    Inside a bash function, $1 is the first argument, $2 is the second, and so on.
  2. Step 2: Identify what $2 means

    $2 specifically refers to the second argument passed to the function when it is called.
  3. Final Answer:

    The second argument passed to the function -> Option B
  4. Quick Check:

    Positional parameter $2 = second argument [OK]
Quick Trick: Remember: $1 is first, $2 is second argument [OK]
Common Mistakes:
MISTAKES
  • Confusing $2 with the function name
  • Thinking $2 is the total argument count
  • Mixing $1 and $2 positions

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bash Scripting Quizzes