0
0
Bash Scriptingscripting~10 mins

set -x for trace mode 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 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'
Atrace -x
Bset +x
Ctrace on
Dset -x
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'set +x' which disables trace mode.
Typing 'trace on' which is not a valid bash command.
2fill in blank
medium

Complete 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'
Atrace off
Bset -x
Cset +x
Dset -e
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'set -x' again which keeps trace mode on.
Typing 'trace off' which is not a bash command.
3fill in blank
hard

Fix 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'
A-X
B-x
Cx
D+x
Attempts:
3 left
💡 Hint
Common Mistakes
Using uppercase '-X' which is invalid.
Using '+x' which disables trace mode.
4fill in blank
hard

Fill 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'
Aset -x
Bset +x
Cset -e
Dset -v
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'set -e' which stops script on errors.
Using 'set -v' which shows input lines but not commands.
5fill in blank
hard

Fill 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'
Aset -x
Bls -l
Cset +x
Dpwd
Attempts:
3 left
💡 Hint
Common Mistakes
Not disabling trace mode after the command.
Running commands before enabling trace mode.