0
0
Bash Scriptingscripting~10 mins

Documentation with comments 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 add a comment in Bash script.

Bash Scripting
[1] This is a comment
Drag options to blanks, or click blank then click option'
A//
B<!--
C#
D/*
Attempts:
3 left
💡 Hint
Common Mistakes
Using // or /* for comments, which are used in other languages.
Forgetting to add the comment character at the start.
2fill in blank
medium

Complete the code to add an inline comment after a command.

Bash Scripting
echo "Hello World" [1] This prints a greeting
Drag options to blanks, or click blank then click option'
A//
B#
C--
D/*
Attempts:
3 left
💡 Hint
Common Mistakes
Using // or -- which are not valid comment markers in Bash.
Placing the comment character before the command.
3fill in blank
hard

Fix the error in the comment syntax to properly document the script.

Bash Scripting
echo "Start script" [1] This is a start message
Drag options to blanks, or click blank then click option'
A#
B//
C<!--
DREM
Attempts:
3 left
💡 Hint
Common Mistakes
Using comment styles from other languages like REM or .
Omitting the comment character entirely.
4fill in blank
hard

Fill both blanks to add a multi-line comment using a common Bash workaround.

Bash Scripting
: [1] This is a multi-line comment
This text is ignored
[2]
Drag options to blanks, or click blank then click option'
A'
B#
C:
D"
Attempts:
3 left
💡 Hint
Common Mistakes
Using # for multi-line comments which only works for single lines.
Not quoting the text after the colon.
5fill in blank
hard

Fill both blanks to document a function with comments.

Bash Scripting
function greet() {
  [1] "Hello, $1!"  [2] # Print greeting
}
Drag options to blanks, or click blank then click option'
A{
Becho
C#
D(
Attempts:
3 left
💡 Hint
Common Mistakes
Using parentheses instead of curly braces for function body.
Forgetting the comment character #.
Using print instead of echo.