Example Analysis of system input and output in linux
Editor to share with you a sample analysis of the input and output of the system in linux, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
1. Understand the input and output of the system
In a linux system, 1 indicates correct output and 2 indicates error output
two。 Symbols for managing input and output
(1) output redirection (output to the specified location)
> # # redirect correct output 2 > # redirect error output & > # redirect all output
Note: the following experiments should be completed among ordinary users
Find / etc/-name passwd > file1 # # directs correct output to file1 (error output that is not in the file will be displayed) find / etc/-name passwd 2 > file2 # # directs error output to file2 (correct output not put in file will be displayed) find / etc/-name passwd & > file3 # # directs all output to file3
File # # clear file (because the source file is overwritten when the'> 'symbol is output, > file overwrites the source file with blank space, which can be emptied)
(2) output append
> > # # append correct output to the last 2 > # # append error output to the end of the file & > > # # append all output to the end of the file
Note: append does not overwrite the contents of the source file
(3) input redirection
& 1 | tee file | wc-lumped # change the error output numbered 2 to the correct output numbered 1 and put it into the file file together and count the number
The above is all the contents of the article "sample Analysis of system input and output in linux". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!