What $0,$1,$2 means in a Linux/unix script

Source: Internet
Author: User
Tags stdin
There are three standard input and output in Linux, namely Stdin,stdout,stderr, the corresponding number is 0,1,2. STDIN is the standard input, read the information by default from the keyboard, stdout is the standard output, by default output output to the terminal, that is, the display and so on, stderr is a standard error message, the default will be displayed on the terminal. Since stdout and stderr are displayed by default on the terminal, in order to distinguish between the information, there is the definition of the number of 0,1,2, with 1 means that stdout,2 represents stderr.

$#: Number of command line arguments

$0: The name of the script

$?: Shell command execution result, if the previous instruction is executed correctly, the value is 0, error is not 0

What $0,$1,$2 means in a Linux/unix script

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.