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
Table of contents Preface zx library $`command` c...
The Docker publishing method provides many conven...
1. Environmental Preparation Tencent Cloud Server...
This article example shares the specific code of ...
Preface: Timestamp fields are often used in MySQL...
Preface The electricity in my residence has been ...
This article mainly introduces the typing effect ...
The specific code is as follows: <style> #t...
This article example shares the specific code of ...
The examples in this article are all written in s...
Preface Note: The test database version is MySQL ...
The default storage directory of mysql is /var/li...
Table of contents Introduction Introduction Aggre...
Table of contents Preface SQL statement optimizat...
1. Data desensitization explanation In daily deve...