- 论坛徽章:
- 5
|
from bash man:
*
Expands to the positional parameters, starting from one. When the expansion occurs within double quotes, it expands to a single word with the value of each parameter separated by the first character of the IFS special variable. That is, "$*" is equivalent to "$1c$2c...", where c is the first character of the value of the IFS variable. If IFS is unset, the parameters are separated by spaces. If IFS is null, the parameters are joined without intervening separators.
@
Expands to the positional parameters, starting from one. When the expansion occurs within double quotes, each parameter expands to a separate word. That is, "$@" is equivalent to "$1" "$2" ... If the double-quoted expansion occurs within a word, the expansion of the first parameter is joined with the beginning part of the original word, and the expansion of the last parameter is joined with the last part of the original word. When there are no positional parameters, "$@" and $@ expand to nothing (i.e., they are removed).
* 参数
扩展为从1开始的位置参数。
双引号对中的*被扩展为单一的word字,这个字的值是由以第一个IFS字符分隔每个位置参数组成的字符序列。
即"$*" 扩展为"$1c$2c..", 其中c是IFS值中的第一个字符。
如果IFS没有定义,那么c为space;如果IFS为空,那么c为空。
@ 参数
扩展为从1开始的位置参数。
双引号对中的@被扩展为多个分开的word字,即"$@" 扩展为"$1" "$2" ...
如果双引号扩展发生在一个字中,如abc"$@"def,扩展后的第一个字与原始字的开头部分abc相连,扩展后的最后一个字与原始字的后面部分def相连。
当没有位置参数时,"$@" 和$@扩展为nothing,即它们被移除。
[ 本帖最后由 blackold 于 2008-1-8 13:06 编辑 ] |
|