Linux Learning Notes 10--pipeline and redefinition

Source: Internet
Author: User
Tags stdin

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.