Questions about running a sub-shell in () (redirection)

Source: Internet
Author: User
About running the sub-shell in () (redirection related)-Linux general technology-Linux technology and application information, the following is a detailed description. Such a command date> desktop/new is easy to understand. The command will redirect the output date to the new file on the desktop, But I entered another (date)> the desktop/new command is used for testing. I think this date will be run in the sub-shell, and the output of date in the sub-shell is not redirected, so date should be printed on the screen of the sub-shell, then return the parent shell, and then run the> desktop/new command. Whatever happens after that, I will enter this command to test it. I didn't expect it to run like it without parentheses. Similarly, the output is redirected to the new file. I cannot figure out why. Then I used another one (date> desktop/son)> desktop/new test. The result shows that the output is redirected to son, and the new content is cleared. I will use the date> desktop/son> desktop/new test (that is, remove the brackets of the previous command ). The result shows that the output date is printed on new, and the son file is cleared. I am using bash. I don't know which man can explain it.
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.