Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to enable trace mode in a bash script.
Bash Scripting
echo "Starting script" [1] echo "This will be traced"
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'set +x' which disables trace mode.
Typing 'trace on' which is not a valid bash command.
✗ Incorrect
The command 'set -x' enables trace mode, showing each command before execution.
2fill in blank
mediumComplete the code to disable trace mode in a bash script.
Bash Scripting
set -x # some commands [1] echo "Trace mode off now"
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'set -x' again which keeps trace mode on.
Typing 'trace off' which is not a bash command.
✗ Incorrect
The command 'set +x' disables trace mode in bash scripts.
3fill in blank
hardFix the error in the code to correctly enable trace mode.
Bash Scripting
echo "Start" set [1] echo "Running commands"
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using uppercase '-X' which is invalid.
Using '+x' which disables trace mode.
✗ Incorrect
The correct flag to enable trace mode is '-x' (lowercase x).
4fill in blank
hardFill both blanks to enable and then disable trace mode around a command.
Bash Scripting
echo "Before trace" [1] echo "Tracing this command" [2] echo "After trace"
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'set -e' which stops script on errors.
Using 'set -v' which shows input lines but not commands.
✗ Incorrect
Use 'set -x' to start trace mode and 'set +x' to stop it.
5fill in blank
hardFill all three blanks to enable trace mode, run a command, and then disable trace mode.
Bash Scripting
[1] echo "Trace mode is on" [2] echo "Trace mode is off" [3]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Not disabling trace mode after the command.
Running commands before enabling trace mode.
✗ Incorrect
Enable trace mode with 'set -x', run 'ls -l', then disable with 'set +x'.