0
0
Bash Scriptingscripting~10 mins

Shebang line (#!/bin/bash) in Bash Scripting - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete 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'
A#!/usr/bin/node
B#!/usr/bin/python
C#!/bin/sh
D#!/bin/bash
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.
2fill in blank
medium

Complete 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'
A#!/bin/bash
B#!/usr/bin/python3
C#!/usr/bin/perl
D#!/bin/sh
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.
3fill in blank
hard

Fix 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'
A#!bin/bash
B#!/bin/bash
C#!/bin/bash script
D#!/bin/bash/
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.
4fill in blank
hard

Fill 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'
A#!/bin/bash
B"Hello, Bash!"
C"Hello, world!"
D#!/usr/bin/python3
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong shebang line.
Forgetting to put the message in quotes.
5fill in blank
hard

Fill 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'
A#!/bin/bash
B"Alice"
C$name
D#!/usr/bin/python3
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong shebang line.
Not quoting the string value.
Not using $ to reference the variable in echo.