Examples of common applications in shell scripts

Source: Internet
Author: User
1. How can I redirect the standard output and error output to the same location at the same time?

There are two ways to achieve this:

Method One: 2>&1

# Ls/usr/share/doc > Out.file 2>&1

The implication is that if a file exists, the result is output to out.file,

Otherwise, the wrong prompt is output to out.file, which enables simultaneous redirection of standard output and error output


Method Two:&>

#ls/usr/share/doc &> Out.file

Explanation: Whether the correct output exists for a file, or the output of an error caused by the absence of a file, the result is redirected to the Out.file (either the correct output or the error output, redirected to Out.file)

This article from "Linux Enthusiasts" blog, declined reprint!

Examples of common applications in shell scripts

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.