Red Flag Linux Desktop 6.0 user manual: Directional and pipeline

Source: Internet
Author: User
Keywords Linux desktop User manual
Tags cat cat command command line data desktop error error message example

Executing a shell command line typically automatically opens three standard files, namely standard input files (stdin), usually the keyboard of the terminal, standard output files (stdout), and standard error output files (stderr), which correspond to the screen of the terminal. Process from standard

The input file gets the data, outputs the normal output data to the standard output file, and sends the error message to the standard error file. As an example of the cat command, the function of the Cat command is to read the data from the file given in the command line and send the data directly to the standard output. For example, the command:

$ cat Config

The contents of the file config will be displayed on the screen in turn. However, if there are no parameters in the cat's command line, it reads the data from standard input and sends it to standard output. For example:

$ cat

Hello World

Hello World

$

The following issues apply directly to standard input/output files:

Data from the standard terminal input, the input data can only be used once, the next time you want to use these data will need to re-enter, and in the terminal input to modify the wrong input is also very inconvenient;

The information that is output to the terminal screen can only be viewed and cannot be modified, and the user cannot do more processing of the output, such as further processing of the output as input to another command. To solve these problems, the Linux system introduces two other mechanisms for input and output transmission, namely, input/output redirection and pipelines.

8.4.1 Input Redirection

Input redirection refers to redirecting the standard input of a command (or executable program) to a specified file, that is, the input can come from a specified file, not from the keyboard. For example, the command WC statistic specifies the number of rows, words, and characters that a file contains. If you type only on the command line:

$ WC

245

The WC will wait for the user's input, and when the shell seems dead, all the text typed from the keyboard appears on the screen, but there is no result until you press <CTRL+D>,WC to write the command results on the screen. If you give a file name as an argument to the WC command, the WC returns the number of rows, words, and characters that the file contains. Another way to pass the contents of a passwd file to the WC command is to redirect the input of the WC. The general form of input redirection is: command < filename you can redirect the input of the WC command to the passwd file with the following command:

$ WC < passwd

20 23 726

Most commands specify the file name of the input file on the command line as parameters, so input redirection is not used frequently. However, when you use a command that does not accept a filename as an input parameter, or if the input you need exists in a file, you can use the input redirect http://www.aliyun.com/zixun/aggregation/7432.html to solve the problem.

Related Article

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.