Skip to content

BASH redirect streams such as STDERR and STDOUT

Example that runs myscript.sh, and redirects all STDERR to STDOUT so you can use a pager.

Terminal window
$ ./myscript.sh 2>&1 | less

The important part is 2>&1, which says STDERR, which is 2, should be redirected to STDOUT, which is 1.

Bash Programing intro