Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete 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'
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.
✗ Incorrect
In Bash scripting, comments start with the # symbol.
2fill in blank
mediumComplete 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using // or -- which are not valid comment markers in Bash.
Placing the comment character before the command.
✗ Incorrect
In Bash, inline comments start with # after the command.
3fill in blank
hardFix 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using comment styles from other languages like REM or .
Omitting the comment character entirely.
✗ Incorrect
Bash uses # for comments; // and REM are invalid here.
4fill in blank
hardFill 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using # for multi-line comments which only works for single lines.
Not quoting the text after the colon.
✗ Incorrect
In Bash, multi-line comments can be simulated using a no-op command : followed by a quoted string.
5fill in blank
hardFill 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using parentheses instead of curly braces for function body.
Forgetting the comment character #.
Using print instead of echo.
✗ Incorrect
Functions in Bash start with { and end with }, echo prints text, and # starts comments.