Bonus: Redirect STDERR

Standard Error

Output stream used to display error messages.


  • 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


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


cat non-existent-file.txt 2> cat-error.log && ls && cat cat-error.log output

Redirect STDERR Append

cat different-file.txt 2>> cat-error.log


cat different-file.txt 2» cat-error.log && cat cat-error.log


You are not expected to know how to redirect STDERR in this course.