$*  –  Positional Parameters

$* expands to a single word, which contains the values of all positional parameters $1, $2, etc.

$@ is similar, but produces multiple values, one for each positional parameter.

Examples

Print positional parameters as one value
1
2
set a b
for p in "$*"; do echo "value: $p"; done
Output:
1
value: a b
Print positional parameters as multiple values
1
2
set a b
for p in "$@"; do echo "value: $p"; done
Output:
1
2
value: a
value: b
BashSupport Pro 是一款 Bash 和 POSIX 集成开发环境,支持 $* - 立即试用
© 2020–2024 Joachim Ansorg
声明
隐私政策
许可条款