Ten sentences to teach you how to redirect data streams in Linux

Source: Internet
Author: User
Ten sentences show you how to redirect data streams in Linux. 1. when you see the redirection, you suddenly think of redirect in the web. that's right, but the function of redirecting data streams in Linux is not to jump to another web page, it is used to store important screen information, and output unnecessary screen information to a file or a black hole... ten sentences show you how to redirect data streams in Linux. 1. when you see the redirection, you suddenly think of redirect in the web. that's right, but the function of redirecting data streams in Linux is not to jump to another web page, it is used to store important screen information, output unnecessary screen information to a file or "black hole", store error information and correct information separately, or only display correct information ~ 2. data stream redirection is divided into standard input (the code is 0 and <或<<)、标准输出(代码为1,使用> Or>), standard error (code is 2, use 2> or 2>) to output these three types. 3. standard input> Example: ls-l/> dir.txt contains 4 bytes. if you want to continue output in dir.txt but do not overwrite the previous information, use >>, such as ls/home> dir.txtto check dir.txt, the ls/home results are added at the end. If you use>, the preceding content will be overwritten.> Output cannot be accumulated! 5. if you want to input the content in another file to dir.txt, you can cat> dir.txt. > Dir.txt Right_lisit 2> wrong_list must use 2> output error Information 7. some errors have been known beforehand and are irrelevant. it is not necessary to display them on the screen or store them in files, you can find dir.txt qwert 2>/dev/null to throw the error message to "black hole ~, If you are interested, go to/dev/null. let's take a look ~ Nothing in it... 8. if you want to record both the correct information and error information, find dir.txt qwert> list.txt 2> & 1 9. you can also create a file through> ~ Cat> newfile 10, and < <没有介绍,这个和他的“另一半”> > It can be different. it does not mean accumulation, but the end of the input. For example: cat> newfile <"over", then you can enter the content of the file. 12345 go up the hill and fight the tiger over and execute the cat newfile command. you can see that there is no over word in the file ~, Over is just a identifier defined by us as the end of input ~
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.