Shell standard error redirection to standard output

Source: Internet
Author: User
Shell standard error redirection to standard output 2 & gt; & amp; 1 is to redirect standard errors to standard output the second problem is very simple: use this command to achieve: cat/etc/passwd | greproot | cut-d & quot;: & quot;-f1 :~ $ Cat/etc/passwd... shell standard error redirection to standard output 2> & 1 is to redirect standard errors to standard output the second problem is simple: use this command to achieve: cat/etc/passwd | grep root | cut-d ":"-f1 implementation :~ $ Cat/etc/passwd | grep root | cut-d ":"-f1 root. what do you mean? Q: Yes. what does this mean? what does this operator mean? Save it. Answer> it means output redirection.> Rewrite in overwrite mode> append mode. 1 indicates the standard output, and 2 indicates the error message output. & 1 indicates the standard output. The last & symbol indicates the backend execution. Let me look for an example. please study it with patience: ls hanls: Cannot access han: no file or directory for execution ~ $ Ls han> 1.txt 2> & 1 is not displayed in shell. then execute ~ $ Cat 1.txt ls: inaccessible han: No such file or directory description error information is redirected to the 1.txt file. If this & ls han> 1.txt 2> 1 is not added, another 1 file will be generated. Cat 1ls: unable to access han: there is no such file or directory. & 1 indicates the logical standard output. Without adding &, a file named 1 will be generated.
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.