Linux shell redirection and shell redirection

Source: Internet
Author: User

Linux shell redirection and shell redirection

Redirects the shell error output to the standard output to record the error information of the script.


For example:

/Root/test. sh> test. log 2> & 1


Note:

Linux first loads/etc/rc. d/rc. local and then/etc/profile



Teach linux shell to redirect a simple question: why does ls-l>/111txt>/222txt not input the results to both files?

Redirection is like this. The command result can only be output to one place. You can understand the principle.
In IO Redirection, stdout or stderr pipelines are always prepared before the command execution result is imported.
In the example you provided, first redirect to/111.txtand then to/222.txt. therefore, the MPs queue is connected to/222.txt. Stdout has only one pipe, and the input end is fixed. You just keep moving the output end. Of course, the last one prevails.

I suggest you go to Shell 13th question, which contains detailed explanations of IO Redirection.

The solution is to use the tee command:
Ls-l | tee/111.txt>/222.txt

How does linux shell redirect the echo content to a variable?

Var2 = $ (echo $ var)
 

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.