The meaning of Shell scripting variable $#,$*,$$,$@,$0,$1,$2,$?

Source: Internet
Author: User

Parameter description

1:$# indicates the number of arguments passed into the script

2:$* indicates the execution of a script passed in the parameter list

3:$$ represents the Process ID

4:[email protected] means that the execution script passes all parameters

5:$0 represents the execution script name

6:$1 represents the first parameter

7:$2 represents the second argument

8:$? Indicates script execution status 0 Normal, other indicates error

Experiments and results (shelltest.sh)
#!/bin/SHEcho "parm number is: $#"Echo "parm list is: $*"Echo "All parm are: [email protected]"Echo "process is: $$"Echo "file name is: $"Echo "The first Parm is: $"Echo "stat is: $?"
Implementation and Results

Execution: Sh shelltest.sh "the first Parm" "The second Parm"

Parm number Is:2
Parm List Is:the First parm the second parm
All Parm is:the First parm the second parm
Process is:28669
File name is:shellTest.sh
The first parm is:the first parm
Stat is:0

Reprinted: 51859503

Shell script variable $#,$*,$$,[email protected], meaning of $0,$1,$2,$?

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.