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.


$ ./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.

Published: Friday, 14 April 2006