$ 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