Bird
0
0

Which of the following is the correct way to write a shebang line for a Bash script?

easy📝 Syntax Q12 of 15
Bash Scripting - Basics
Which of the following is the correct way to write a shebang line for a Bash script?
A!#/bin/bash
B#!/bin/sh
C#!/bash/bin
D#!/bin/bash
Step-by-Step Solution
Solution:
  1. Step 1: Check the correct shebang syntax

    The shebang line must start with #! followed by the full path to the interpreter.
  2. Step 2: Verify the path for Bash

    The correct path for Bash is /bin/bash, so the line is #!/bin/bash.
  3. Final Answer:

    #!/bin/bash -> Option D
  4. Quick Check:

    Shebang = #! + interpreter path [OK]
Quick Trick: Shebang always starts with #! followed by interpreter path [OK]
Common Mistakes:
MISTAKES
  • Swapping the order of # and !
  • Using wrong interpreter path
  • Confusing /bin/sh with /bin/bash (different shells)

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bash Scripting Quizzes