Open files have a Fd:file descriptor (file descriptor)
Standard input: Keyborad, 0
Standard output: monitor, 1
Standard error Output: monitor, 2
I/O redirection: Changing the standard location
output Redirect: command > New_pos, command >> new_pos
Overwrite redirect, the original content in the target file will be erased;
>>: Append redirect, the new content will append to the end of the target file;
# set-c: Suppresses the output of content to an existing file;
Forced Overwrite: >|
# Set +c:
2>: Overwrite redirect error output data stream;
2>>: Append redirect error output data stream;
The standard output and error outputs are directed to different locations:
COMMAND >/path/to/file.out 2>/path/to/error.out
Merge standard output and error output redirect for the same data stream:
&>: Overwrite redirect
&>>: Append redirect
COMMAND >/path/to/file.out 2> &1
COMMAND >>/path/to/file.out 2>> &1
>>x 2>>&1 Normal output to x error output to the same place as normal output (x)
Enter redirect:<
TR command: Convert or delete characters
TR [OPTION] ... SET1 [SET2] convert SET1 to SET2
-D Delete SET1 does not convert
Here documentation:<<
# cat << EOF input from terminal until EOF
# cat >/path/to/somefile << EOF
Pipeline:
COMMAND1 | COMMAND2 | COMMAND3 | The execution of the previous command returns a value to the next command
Note: The last command executes in the child shell process of the current shell process;
Tee Command:
Tee [OPTION] ... [FILE] ...
Typically used in intermediate pipelines, the data entered into the process is output directly to a specified file, the other to the next command (through the pipeline), or directly to the screen
Text Processing tools: WC, cut, sort, uniq
WC Command: Statistics article details
WC [OPTION] ... [FILE] ...
-l:lines count rows
-w:words statistics of words
-c:characters count Words
Cut Command: Cut the article as required
Cut [OPTION] ... [FILE] ...
- D DELIMITER: Indicates delimiter
-F Fileds: Specifies that paragraphs are taken after splitting
#: Section # Fields
#,#[,#]: Discrete multiple fields, such as 1,3,6
#-#: Multiple consecutive fields, such as 1-6
Mixed use: 1-3,7
--output-delimiter=string
Sort command: Sort
Sort [OPTION] ... [FILE] ...
-F: Ignore character case
-R: Reverse order
- t DELIMITER: Field delimiter
-K #: Sort the specified fields as standard
-N: Sorting by numeric size
-u:uniq, after sorting, went heavy, near to heavy
uniq Command:
Uniq [OPTION] ... [FILE] ...
-C: Shows the number of repetitions of each line;
-D: Show only the rows that have been repeated;
-U: Displays only rows that have not been duplicated;
Linux Learning Diary--Basic Commands (4)--Text processing, redirection, pipelines