Bonus: Redirect STDERR
Standard Error
Output stream used to display error messages.
Example
- broken bash command with a redirect into
error.log
file
Redirect STDERR
By default any error messages in STDERR
are sent to the terminal window of the CLI shell.
cat non-existent-file.txt
Output:
cat: non-existent-file.txt: No such file or directory
Redirect STDERR
Write
STDERR
can be redirected and written, or appended to a file similar to STDOUT
, by using the write file 2>
and append file 2>>
redirection operators.
cat non-existent-file.txt 2> cat-error.log
Output:
Redirect STDERR
Append
cat different-file.txt 2>> cat-error.log
Output:
Note
You are not expected to know how to redirect STDERR
in this course.