Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to write the correct shebang line for a Bash script.
Bash Scripting
[1] Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a Python or Node.js shebang line in a Bash script.
Forgetting the '#!' at the start of the line.
✗ Incorrect
The shebang line for Bash scripts is always '#!/bin/bash' to tell the system to use the Bash shell.
2fill in blank
mediumComplete the code to start a Bash script with the correct shebang line.
Bash Scripting
[1] echo "Hello, world!"
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '#!/bin/sh' which may not support all Bash features.
Using a Python or Perl shebang line by mistake.
✗ Incorrect
The correct shebang for Bash scripts is '#!/bin/bash'. This tells the system to run the script with Bash.
3fill in blank
hardFix the error in the shebang line to correctly run the script with Bash.
Bash Scripting
[1] echo "Script is running"
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Adding a trailing slash after '/bin/bash'.
Omitting the leading slash in the path.
Adding extra words after the interpreter path.
✗ Incorrect
The shebang line must be exactly '#!/bin/bash' with no extra characters or spaces.
4fill in blank
hardFill both blanks to write a Bash script that starts with the correct shebang and prints a message.
Bash Scripting
[1] echo [2]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong shebang line.
Forgetting to put the message in quotes.
✗ Incorrect
The script must start with '#!/bin/bash' and use echo to print the message 'Hello, world!'.
5fill in blank
hardFill all three blanks to create a Bash script with the correct shebang, a variable assignment, and a print statement.
Bash Scripting
[1] name=[2] echo "Hello, [3]!"
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong shebang line.
Not quoting the string value.
Not using $ to reference the variable in echo.
✗ Incorrect
The script starts with '#!/bin/bash', assigns the string 'Alice' to variable name, and prints 'Hello, Alice!' using the variable.