Recall & Review
beginner
What is the purpose of the shebang line
#!/bin/bash in a script?The shebang line tells the system which program to use to run the script.
#!/bin/bash means the script will run using the Bash shell.Click to reveal answer
beginner
Where should the shebang line be placed in a script file?
The shebang line must be the very first line in the script file, with no blank lines or spaces before it.
Click to reveal answer
intermediate
What happens if a script does not have a shebang line?
If there is no shebang line, the script may run with the default shell, which might not be Bash. This can cause errors if the script uses Bash-specific features.
Click to reveal answer
intermediate
Can the shebang line specify a program other than Bash? Give an example.
Yes. For example,
#!/usr/bin/python3 tells the system to run the script with Python 3 instead of Bash.Click to reveal answer
advanced
Explain why the shebang line is important for script portability.
The shebang line ensures the script runs with the intended interpreter on different systems, making the script portable and predictable.
Click to reveal answer
What does the shebang line
#!/bin/bash do in a script?✗ Incorrect
The shebang line tells the system to use Bash to run the script.
Where must the shebang line be placed in a script?
✗ Incorrect
The shebang line must be the first line to be recognized by the system.
What might happen if a script with Bash commands lacks a shebang line?
✗ Incorrect
Without a shebang, the system may use a default shell that does not support Bash commands.
Which of these is a valid alternative shebang line for a Python script?
✗ Incorrect
The line #!/usr/bin/python3 tells the system to run the script with Python 3.
Why is the shebang line important for script portability?
✗ Incorrect
The shebang line makes sure the script uses the correct program to run, helping it work on many systems.
Describe what the shebang line
#!/bin/bash does and why it is important in a script.Think about how the system knows which program to use to run your script.
You got /4 concepts.
Explain what could happen if you run a Bash script without a shebang line.
Consider what happens if the system guesses the program to run your script.
You got /4 concepts.