Management of input and output in the system 1. Understand the input and output of the system In Linux system, 1 indicates correct output and 2 indicates incorrect output 2. Manage input and output symbols (1) Output redirection (output to a 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 ##Direct correct output to file1 (wrong output that is not put into the file will be displayed) find /etc/ -name passwd 2> file2 ##Direct error output to file2 (will display correct output that was not put into the file) find /etc/ -name passwd &> file3 ##Direct all output to file3 file ##Clear file (because the '>' symbol will overwrite the source file when it is output, so > file will overwrite the source file with a blank space to achieve the effect of clearing) (2) Output append >> ##Append correct output to the end of the file 2>> ##Append error output to the end of the file&>> ##Append all output to the end of the file Note: Appending will not overwrite the original file contents (3) Input redirection <<EOF content EOF (EOF here can be any combination, but it needs to be the same before and after) for example: vim file Enter passwd student<<EOF heihei heihei EOF Command line input file ##Modify student user password 3. Pipeline Function: turns the output of the previous command into the input of the next command in the pipeline Note: The pipeline only allows correct output to pass. If you want incorrect output, you should use 2>&1 to convert the incorrect output number into the correct output number before outputting it. | ##Turn the correct output of the first command into the input of the second command after the pipeline 2>&1 ##Turn the error output numbered 2 into the correct output numbered 1 tee ##Copy the output to the specified location For example: ls /bin |wc -l ##Count how many files there are in /bin find /etc/ -name passwd 2>&1 | wc -l ##Turn the error output numbered 2 into the correct output numbered 1 and count the number find/etc/ -name passwd 2>&1 | tee file |wc -l ##Turn the error output numbered 2 into the correct output numbered 1 and put them into the file file and count the number Summarize The above is the full content of this article. I hope that the content of this article will have certain reference learning value for your study or work. Thank you for your support of 123WORDPRESS.COM. You may also be interested in:
|
<<: Optimizing the performance of paging query for MySQL with tens of millions of data
>>: Summary of twelve methods of Vue value transfer
This article shares the specific code of native j...
Disable right-click menu <body oncontextmenu=s...
If a form field in a form is set to disabled, the ...
Table of contents 1. Synchronization Principle 2....
The main text page of TW used to have a width of 8...
This article example shares the specific code of ...
mysql query control statements Field deduplicatio...
Prerequisites Compose is a tool for orchestrating...
This article shares the specific code of js to im...
Priority The reason why placing the same conditio...
I just installed Ubuntu and there was no network ...
Table of contents Query cache optimization Overvi...
Table of contents What is a web container? The Na...
Today, I encountered a little problem when I was ...
Preface In case of application bug or DBA misoper...