Shell Special position variable ($0,$1$2,$*,$#,$$,$?,$@,${})

Source: Internet
Author: User

$ file name and path

$1,$2 parameter 1, parameter 2

$#     The number of arguments passed to the script or function

current shell process ID

judge execution succeeded or not 0 for success

[email protected] Pass all parameters of a script or function

$*     Pass all parameters of a script or function

${}

Note: [Email protected] and the $* 's All Pass all parameters of a script or function. When enclosed by double quotation marks , the two have the following differences

[email protected] shell]# cat 007.sh

#!/bin/bash

For var in " [email protected] "

Do

echo "$var"

Done

[[Email protected] shell]# sh 007.sh feng cx Xiao

Feng

Cx

Xiao

[email protected] shell]# cat 007.sh

#!/bin/bash

For Var in "$*"

Do

echo "$var"

Done

[[Email protected] shell]# sh 007.sh feng cx Xiao

Feng Cx Xiao

$var and ${var} Differences

such as: When you want to display variable values with random characters

Echo $var _ AA $var will use the _aa later as part of the variable.

Echo ${var}_aa ${var} does not use the following _aa as part of a variable


This article is from the "Feng" blog, make sure to keep this source http://fengxiaoli.blog.51cto.com/12104465/1952185

Shell Special position variable ($0,$1$2,$*,$#,$$,$?,[email protected], ${})

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.