I. application tools in the filter Linux system are divided into three types: the interactive tool, the filter editor, which can accept data and filter and output the data. these tools are called filters and processes, there are input source and output objects. 2. input, output, and redirect input: filter
I. filter
There are three types of application tools in Linux:
Interactive tools
Filter
Editor
A tool that can accept data and filter and output data is called a filter.
There are input source and output objects for filters and processes.
II. input, output, and redirection
Input: data source of the filter
-- Standard input stdin (0): default value: Keyboard
Output: data destination of the filter
-- Stdout (1): terminal screen by default
Error output: the error message follows a different I/O channel from the standard output.
-- Stderr (2) for standard error output: terminal screen by default
Redirection: standard input, output, and error output can all be changed using specific symbols.
III. input redirection
Use "<" to redirect the input source
Most tools use the following file name as the input source.
Some filters must be added to specify the input source.
Cmond <file (reads files from the keyboard input)
As shown above, replace all uppercase characters in. pash_profile with lowercase characters.
IV. input from current document
Use <to enable the system to input all the input on the keyboard at a time, first send it to the virtual "current document", and then enter the input at a time.
A letter, symbol, or string is required as the start identifier.
You can select any symbol as the start identifier.
5. output redirection
Use> Change data output target
Example: ls-l> listfile
Display the files in the current directory in long mode and write them to the listfile file.
All existing file content will be deleted
VI. coverage and append
Use> to redirect the output. The original content of the file will be overwritten.
Ls-l> listfile
Use> to add output to a file
Ls-l> listfile
VII. Error output redirection
System errors are different from standard output I/O pipelines
By default, system errors are displayed on the terminal screen.
Use 2> redirect error messages to a file
Find/-type s 2>/dev/null
Use 2> add an error message to a file
Find/-name passwd 2> results
8. Dual output redirection
Use> and 2> to send the correct and incorrect input of an operation separately to different places:
Find/-perm-2 2> error> results
Use &> to send all input to the same place:
Find/-perm + 6000> file
Another method
9. pipelines
Use | directly sends the output of the previous filter to the input of the next filter
Ls-l | grep pass
Allow multiple pipelines
Note that the output of the filter before the MPs queue matches the input data type of the MPs queue filter.
10. common examples of redirection and pipelines
Ls-l | more
Display files in the current directory on the split screen
Cat <filea> fileb
Copy filea to fileb
Cat file. *> file
Merge several small files into one file