The computer consists of: an operator, a controller, a memory, a input. So there is the address bus, data bus, control bus. In fact, in the machine the bus is multiplexed, a bus three functions.
Address bus: Memory addressing
Data bus: Transferring data
Control Summary: Control instructions
Register: CPU Ephemeral memory
The program obtains instructions from the input device at run time and outputs the output device as a human-computer interaction. Where does the system get the input and output keyboard mouse hard disk or where? Then the system needs to set the default input and output.
System settings
- Default output device: Standard output, STDOUT, 1 (1 for description)
- Default input device: standard input, STDIN, 0
- Standard error Output: STDERR, 2
Standard input: Keyboard
Standard output and Error output: Display (inexpensive, unlike a printer)
I/O redirection (input/output redirection): Changes the input source of the data and changes the output source of the data.
In Linux, the output redirection symbol is ">" Input Redirect "<"
Output redirection
A greater than sign >: Overwrite output
Two greater than sign >>: Append output
For example: ls/etc the ETC directory output to the screen, output redirection: ls/etc >/tmp/etc.out the file directory of etc is exported to the file
If the output in production is accidentally used to overwrite the output can be set with set-c.
SET-C: Prohibit overwrite redirection for already existing files;
In case of-C, if you want to force overwrite the output, use the >|
Set +c: Turn off the above features
If the output redirection uses the wrong output and you want to output the wrong output to a file, how do I use it?
2>: Redirect Error output
2>>: Append method
You want to target both standard output and error output:
Ls/varr >/tmp/var.out 2>/tmp/war.errout (if the command is correct, output the standard output to/tmp/var.out. If the command is wrong, outputting the error command to/tmp/var.errout can also be directed to the same file.
&>: Redirect standard output or error output to the same file
Ls/varr &>/tmp/var.out
Input redirect
<: Input redirection
For example: TR ' A-Z ' A-Z ' </etc/fstab (/etc/fatab all lowercase of this file into uppercase)
<<:here document (Generate documents here)
Example: Cat << END
Print some data
End of the end will output this data
Example: Cat >>/tmp/myfile.txt << END
The first line
The seconf Line
Cat/tmp/myfile.txt
The first line
The seconf Line
Pipeline: The output of the previous command, as input to the latter command
The important philosophical thought of Linux: Combining small commands to complete complex tasks
Command 1 | Command 2 | Command 3 | ...
For example echo "Hello World" | Tr ' A-Z ' A-Z
HELLO World
echo "Redhat" |passwd--stdin User (change user's password to redhat)
cut-d:-f3/etc/passwd |sort-n
Linux Learning Notes 10--pipeline and redefinition