Linux Learning Fifth Lesson-standard I/O and piping

Source: Internet
Author: User

Linux Learning Fifth session

--------------------------------------------------------------------------------------------------------------- ---------------------------------------------------

31. Standard input and output

Program: Instruction + data

Read-in data: Input

Outputs data: Output

Open files have a Fd:file descriptor (file descriptor)

Linux provides three I/O devices to Programs

Standard input (STDIN)-0 accepts input from the keyboard by default

Standard output (STDOUT)-1 Default output to terminal window

Standard error (STDERR)-2 default output to terminal window

I/O redirection: Changing the default location


32. Operation Symbol

> redirect the stdout to a file and output the correct results to a file;

2> redirect the stderr to the file, the wrong prompt output to the file;

&> Redirect all outputs to a file and output all the results to a file;

>> additional content;

2> Overwrite redirect error output data stream;

2>>-weighted directional error output data stream;

&> overlay redirection;

&>> pursuit of heavier orientation;

Command > File 2>&1 (Order is important);

Command >>/path/to/file.out 2>&1;

(): Merging the stdout of multiple programs (command 1; command 2) > all.txt;

< REDIRECT standard input, can be understood as influence, tr ' A-Z ' A-Z ' </ETC/ISSUE,TR command results in effects to/etc/issue, so that all lowercase letters under the file become uppercase;

Cat > File input After enter will appear the cursor flashing, enter the input file files have content;

Cat > Filea < Fileb after input Fileb file contents will appear in Filea;

<< termination words, mail or script at the beginning of the text, the input after the end of the word is terminated, generally with EOF


33. Pipeline

Command 1| Command 2| command 3| .... Pass the correct result of command 1 to command 2, the correct result after processing to the command 3, and so on, this command only transmits the correct results, if you want to pass the error result also, you can use 2>&1 or |&



Linux Learning Fifth Lesson-standard I/O and piping

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.