Standard input: Keyboard
Standard output: Display
Error Output: Display
FD: File Descriptor: Allows the program to interact with the file, and facilitates the kernel to identify the file, each open file has a descriptor
The program interacts with the file interactively, through the file descriptor, rather than the file name, and the file name is user-friendly separately.
Linux all files, so standard input, standard output has its own file descriptor
Standard input Descriptor: 0
Standard Output Descriptor: 1
Standard error Output Descriptor: 2
To change its default data stream to another device: IO redirection
Output redirection
> Overwrite redirects
>> Chasing heavier orientation
/dev/null Black Hole
For the current shell only
sed-c filename Turn off output redirection: If the output file exists, overwrite is not allowed
Forced Overwrite: >|
sed +c filename Start output redirection function
Also define standard output and standard error redirection to different files
COMMAND >/tmp/aa.txt 2>/tmp/bb.txt
REDIRECT standard input and standard error output to the same file
COMMAND & >/dev/null
COMMAND & >>/dev/null
Input redirect
<
COMMAND </filename
<< Create file here
Cat > FileName << EOF is typically used for production files in scripts
Adasd
Asdasd
EOF End Character
Cat << EOF is typically used to output a large segment of information to the user
Sdfsf
Sdfsdf
EOF End Character
Pipeline | : The output of one command is redirected to another command as a parameter using the
COMMAND | COMMAND |
The last command of the pipeline, executed in the child shell of the current shell
Tee
The multi-channel output is output on the screen, and the output is saved in only one file
cat/etc/passwd | Tee filename
#######################################################
Cat-n filename Display file line number
Head-n fetching n rows of file contents: From the first line to the nth row
Tail-n fetching n rows of file contents: from the last line to the nth row
This article is from the "Hanging Sword" blog, please be sure to keep this source http://sublime.blog.51cto.com/8856101/1439610