Linux default command takes input from the standard input device (stdin), and outputs the result to the standard output device (stdout) display. Under normal circumstances, the standard input device is a keyboard. Standard output is a terminal device (monitor).
Under normal circumstances, each command runtime opens three files:
Standard input file (stdin): stdin file descriptor to 0. linux default program reads data from stdin
Standard output file (stdout): stdout file descriptor 1. linux program more with stdout output data.
Standard error (stderr): stderr file descriptor 2. linux program will write an error message to stderr stream.
Output Output redirection
Redirect formats available
/ Dev / null file
/ Dev / null is a special file that is written to its internal content will be discarded.
$ Date> date.txt # results date command is redirected to file date.txt
$ Ll >> date.txt # results ll command appended to the file date.txt
$ Cat date2.txt # contents of the file date.txt redirected to the file date2.txt
String $ cat << EOF # print from the keyboard input to the display, up until the input EOF
$ ./test 2> result.txt # test script will execute an error message is redirected to a file result
$ ./test >> Result.txt 2> & 1 # and output an error message will be performed to test the script appending redirected to a file result.txt