How to redirect standard error in bash

Originally published at: https://www.cyberciti.biz/faq/how-to-redirect-standard-error-in-bash/

I am trying to redirect bash message into file named output.log. But, it is not getting redirected. How do I redirect both standard output and standard error in bash shell? In Linux, how do I redirect error messages? Standard error (also known as stderr) is the default error output device. Use stderr to write all…

This should do <your_command> > out.log 2> error.log

Ex: ls out.log 2>error.log