Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to redirect error messages to a file, replacing its content.
Linux CLI
ls /nonexistent_directory [1] error.log Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '>' redirects standard output, not error.
Using '>>' appends instead of replacing.
✗ Incorrect
Using '2>' redirects the standard error (stderr) to the file, replacing its content.
2fill in blank
mediumComplete the code to append error messages to a file without overwriting it.
Linux CLI
grep 'pattern' file.txt [1] errors.log
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '2>' overwrites the file instead of appending.
Using '>>' redirects standard output, not error.
✗ Incorrect
Using '2>>' appends the standard error output to the file without overwriting existing content.
3fill in blank
hardFix the error in the code to correctly redirect only error messages to a file.
Linux CLI
cat missingfile.txt [1] errors.txt Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '>' redirects standard output, missing error messages.
Using '1>' redirects standard output, not error.
✗ Incorrect
To redirect only error messages, use '2>' which targets stderr.
4fill in blank
hardFill both blanks to redirect standard output to output.log and append errors to error.log.
Linux CLI
command [1] output.log [2] error.log
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '2>' instead of '2>>' will overwrite error.log.
Using '>>' for standard output appends instead of overwriting.
✗ Incorrect
Use '>' to overwrite standard output file and '2>>' to append errors to error.log.
5fill in blank
hardFill all three blanks to redirect standard output to output.log, overwrite errors to error.log, and append errors to error_append.log.
Linux CLI
cmd [1] output.log [2] error.log [3] error_append.log
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up '2>' and '2>>' causes wrong file behavior.
Using '>>' without '2' redirects standard output, not errors.
✗ Incorrect
Use '>' to overwrite standard output, '2>' to overwrite errors, and '2>>' to append errors.