Linux Data stream Redirection

Source: Internet
Author: User

1. Standard output: Code is 1, use > and >>, the former is overlay, the latter is append.
xxx > Aaa.txt
XXX >> Aaa.txt

2, for the wrong data, you need to use standard error output, standard error output: Code is 2, using 2> and 2>>

3, normal information and error message output to a different file, as follows:
XXX >info.txt 2>err.txt

4, normal information and error information output to the same file,
XXX >info.txt 2>info.txt is the wrong wording, info.txt content will be confused. The correct wording is:
XXX >info.txt 2>&1

5, if the information do not want to display and do not want to store it, such as the history of operations, for security, do not want to store. What to do?
Using black hole devices, xxx >/dev/null 2>&1

6, the standard input, the code is 0, use < and <<, solve the problem will originally need to keyboard output data, changed from the file read.

7, Cat >tmp.txt from the keyboard input data to tmp.txt,ctrl+d end input. If read from another file, yes: Cat >tmp.txt <aaa.txt.

8. Standard input,<< indicates that an input is encountered and an end is entered. As follows:
[[email protected] home]# cat >tmp.txt << ' 0 '
> AAA
> BBB
> 0
[Email protected] home]#
After entering 0, press ENTER to end the input and no ctrl+d to exit the input.

Linux Data stream Redirection

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.