Linux Standard Input and Output
After linux is started, three file descriptors are opened by default, namely standard input 0, standard output 1, and error output 2. The new file binding descriptor can be added in sequence. A shell command inherits the file descriptor of the parent process. Therefore, all running shell commands have three default file descriptors. If a command is run, the following command is input: input can be obtained from the keyboard or file. The command is executed successfully and the result is output to the screen: by default, standard output has an error in the execution of on-screen commands: errors will also be output to the screen: by default, standard error means that the input and output of a screen file is tracked as an integer handle of all open files of a given process. These numeric values are file descriptors. The most known object descriptor is stdin, stdout, and stderr. The object descriptor numbers are 0, 1 and 2, respectively. These numbers are retained with their respective devices. Before executing a command, all input and output are prepared. By default, all input and output (stdin, stdout, and stderr) are bound separately. If an error occurs at this time, the command is terminated and will not be executed. For more information about the Command Parsing process, see Linux Shell wildcards, metacharacters, and escape characters. These default outputs are provided in linux, sometimes you do not want the execution result to be output to the screen. I want to output data to files or other devices. At this time, we need to redirect the output. Common Input and Output operators in linux shell are: 1. standard input (stdin): the code is 0. Use <or </dev/stdin->/proc/self/fd/0 0 to indicate:/dev/stdin 2. standard output (stdout): the code is 1. Use> or>;/dev/stdout->/proc/self/fd/1 to indicate: /dev/stdout3. standard error output (stderr): the code is 2, Use 2> or 2>;/dev/stderr->/proc/self/fd/2 2 stands: /dev/stderr records a piece of code. 1 #! /Bin/sh 2 # Check the running parameters of the script. if the parameter is not equal to two, exit script 3 if [! $ #-Eq 2]; then 4 echo "Usage: Need parameters! Run: $0 2015 10 02 "5 exit 6 fi 7 # Run code 8 echo" Para1: $0 "# Name of the executed script 9 echo" Para2: $1 "# The first parameter 10 echo" Para3: $2 "# The second parameter 11 echo" Para4: $3 "# The third parameter of the executed script 12 echo" Para10 :$ {10} "# The Tenth parameter of the executed script 13 echo" Para11: $ {11} "# executed script 11th parameters 14 echo" Para5: $ # "# Number of executed script parameters 15 echo" Para6: $? "# When the previous code or shell program exits in the shell, if it Exits normally, 0 is returned, and the non-0 value is 16 echo" Para7: $ @ "# The parameter list is passed to the script. Each parameter is separated by spaces to form a string 17 echo" Para8: $ * "# The Script parameter list, which is used as a parameter group, 18 echo "Para9: $" # current process ID19 echo "Para1: $-" # display the current options used by Shell, the function is the same as that of the set command. 20 echo "Para2: $! "# The last process ID Fetty running in the background: the name, gender, age, and specific occupation are unknown, and no contact information is available. My blog post (including but not limited to: Simplified Chinese, English, punctuation marks, images, and any combination of the above) the results are all results of typing on the keyboard, mouse, screen, and other tools. It does not represent my own point of view to test the mechanical and photoelectric properties of my computer and display. It is a great honor to share the same ideas!