1. Output redirection
In Linux, because the user has different permissions, access to certain files or directories will be rejected to form an error output, the output of these errors will also be displayed. Normally the correct output is numbered 1, and the error output is numbered 2. For example, in the ordinary user student access to the "/etc/passwd" file, there will be different output. Output management is needed to redirect the output.
You can use the command ">" "2>" "&>" to redirect the correct, error, and full output. If the input command "Find/etc-name passwd >right", is to redirect the correct output to the right file, the wrong output will be displayed directly.
The input command "Find/etc-name passwd 2>error" is to redirect the wrong output to the error file.
The input command "Find/etc-name passwd &>all" is to redirect all output to the all file.
It is important to note that the ">" redirect will overwrite the original file. If you want to overwrite the original file, you need to change ">" to ">>", for example, enter "Find/etc-name passwd >>right" to redirect the correct input to the right file without overwriting the original file.
2. Pipeline
In order to simplify the order, but also for convenience, sometimes need to use the pipeline, the role of the pipeline is to change the output of the previous command into the input of the pipeline command, such as to see how many files and directories under "/etc", use "ls/etc" and then go to the number which is unrealistic, if using the command "LS/ETC | Wc-l "command, you can count it. This command is through the pipe "|" The input of the previous command "LS/ETC" is re-entered into "Wc-l", and the number of directories and files under "/etc" is counted.
If you need to copy the output to the specified location, you need to use "tee". For example, to copy the statistical results from the above command to the output file, enter the command "LS/ETC | Wc-l | Tee output "can be achieved.
The above introduction is only the basic operation of input and output management, but also need to learn more about the application in the later learning and work.
Linux beginner-Output input management