Understanding I/O streams numbers.

Handle Name Description
0 stdin Standard input
1 stdout Standard output
2 stderr Standard error

Redirecting the standard error stream to a file. The following will redirect program error message to a file called error.log:

$ program-name 2> error.log
$ command1 2> error.log

Redirecting the standard error (stderr) and stdout to file
Use the following syntax:

$ command-name &>file

OR

$ command > file-name 2>&1

Another useful example:
$ find /usr/home -name .profile 2>&1 | more

Leave a Reply

Your email address will not be published. Required fields are marked *

*