Redirection for the make use of Linux

Source: Internet
Author: User
Tags stdin

In Linux, the scripting language environment, that is, you use make xxx that other common Linux commands, such as Ls,find, and so on, different numbers, representing different meanings:

Digital Meaning Standard term
0 Standard input stdin = Standard input
1 Standard output stdout = standard output
2 Standard error Output stderr = Standard Error

and the system default Stdin,stdout,stderr, is the screen, so, when you execute commands, such as make, after the output of the information can be seen on the screen.

Therefore, want to output the corresponding information to a file, the corresponding number with the redirect symbol ' > ', the implementation of this information, redirected to the corresponding file, you can.

(The above two sentences, but also before too many people to explain, but did not indicate the white place.) )

The following example shows the Make command, how to output the corresponding information to the corresponding file:

1. The most common way to export all the information from make output to a file is:
Make xxx > Build_output.txt
At this point, the default is not to change the output mode of the 2=stderr, or the screen, so if there is an error message, you can see on the screen.
2. Simply output the error (and warning) information in the make output to the file, ING, you can use:
Make xxx 2> build_output.txt
Accordingly, since the 1=stdout is not changed, or the screen, so, those command execution time output of normal information, or will be output to the screen, you can still see on the screen.
3. Simply output the normal (non-error, non-warning) information in the make output to a file that can be used:
Make xxx 1> build_output.txt
Correspondingly, because the 2=stderr is not changed, or the screen, so, those command execution time output error message, or will be output to the screen, you can still see on the screen.
4. To export normal output information and error messages to separate files, you can use:
Make xxx 1> build_output_normal.txt 2>build_output_error.txt
That is, the combined use of 1 and 2, normal information and error messages, are exported to the corresponding file.
5. All the information is exported to the same file:
Make xxx > Build_output_all.txt 2>&1
The 2>&1 indicates that the error message is output to &1, and &1 refers to the previous file: Build_output_all.txt.
Note: All of the above numbers, followed by the greater than the number ' > ', the middle can not have spaces.

Redirection for the make use of Linux

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.