0
0
Bash Scriptingscripting~10 mins

Error logging patterns 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 redirect error messages to a log file.

Bash Scripting
command [1] error.log
Drag options to blanks, or click blank then click option'
A>
B>>
C2>
D2>>
Attempts:
3 left
💡 Hint
Common Mistakes
Using > instead of 2> redirects standard output, not errors.
Using >> appends output but may not redirect errors.
2fill in blank
medium

Complete the code to append error messages to a log file without overwriting it.

Bash Scripting
command [1] error.log
Drag options to blanks, or click blank then click option'
A>>
B2>
C>
D2>>
Attempts:
3 left
💡 Hint
Common Mistakes
Using 2> overwrites the file instead of appending.
Using >> appends standard output, not errors.
3fill in blank
hard

Fix the error in the code to redirect both standard output and error to the same log file.

Bash Scripting
command > log.txt [1] log.txt
Drag options to blanks, or click blank then click option'
A2>&1
B2>>
C2>
D2>&2
Attempts:
3 left
💡 Hint
Common Mistakes
Using 2> redirects error separately, not combined.
Using 2>&2 does nothing as it redirects error to itself.
4fill in blank
hard

Fill both blanks to redirect standard output to a file and standard error to another file.

Bash Scripting
command [1] out.log [2] err.log
Drag options to blanks, or click blank then click option'
A>
B2>
C>>
D2>>
Attempts:
3 left
💡 Hint
Common Mistakes
Using 2>> for standard output is incorrect.
Using > for errors does not redirect error stream.
5fill in blank
hard

Fill all three blanks to redirect standard output to append to a file, standard error to append to another file, and combine both outputs to the console.

Bash Scripting
command [1] out.log [2] err.log [3]
Drag options to blanks, or click blank then click option'
A>>
B2>>
C2>&1
D| tee -a
Attempts:
3 left
💡 Hint
Common Mistakes
Using > instead of >> overwrites files.
Not using tee means output won't show on console.