$ variables reserved in Linux

Source: Internet
Author: User

$ A The file name of the bash script means that the first parameter, $*, represents the parameter list. [email protected] means "$"/"$ $" ... Each variable is independent, surrounded by double quotation marks $ #表示参数列表个数 $? Indicates the result of the previous command $! the PID number of the previous command note: $* Each word is treated as a separate word using the "$*" argument list as a parameter does not refer to #@ and $* "[ Email protected] "Keep the caller's assumptions, as a parameter within the quotation marks, and leave the script code below the space to test the $* and [email protected] accordingly
1#!/bin/Bash2 3# The differences between $* [email protected]"$*" "[email protected]"4 5 EchoDollar Star is $*# space is not preserved6 Echo "Dollar star in double quotes is $*"# Spaces within quotation marks are preserved7 EchoDollar at is [email protected] # space not reserved8 Echo "Dollar at double quotes are [email protected]"#引号的空格被保留9 Ten Echo One Echo "looping through Dollar Star"# do not quote $*Each word is treated as a separate word. A  forIinch$* -  Do -         Echo "Parameter is $i" the  Done -  - Echo - Echo "looping through Dollar Star with double quotes"# Use"$*"the entire parameter list is treated as a parameter +  forIinch "$*" -  Do +         Echo "Parameter is $i" A  Done at  - Echo - Echo "looping through Dollar at"# non-quoted #@ and $*same -  forIinch[email protected] -  Do -         Echo "Parameter is $i" in  Done -  to Echo + Echo "looping through Dollar at double quotes"#"[email protected]"keep the caller's assumptions, as a parameter within the quotation marks, and leave a space -  forIinch "[email protected]" the  Do *         Echo "Parameter is $i" $  Done

To run the command:

Bash 01defaultParam. SH  " Hello World "The

Execution Result:

Dollar star is the Hello World twodollar star in double quotes are Hello World twodollar at was Hello World twodollar at Doub Le quotes is the Hello World, looping through Dollar Starparameter is Helloparameter are worldparameter looping GH Dollar Star with double quotesparameter are Hello World, looping through Dollar Atparameter is Helloparameter Dparameter is the looping through Dollar at double Quotesparameter was Hello Worldparameter is the

Corresponding Sina blog address: http://blog.sina.com.cn/s/blog_6941438f0102v8qj.html

$ variables reserved in Linux

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.