$@  –  Positional Parameters

$@ expands to the positional parameters $1, $2, etc. producing one field for each parameter.

$* is similar, but only produces a single value, which contains all values at once.

Examples

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
Print positional parameters as one value
1
2
set a b
for p in "$*"; do echo "value: $p"; done
Output:
1
value: a b
BashSupport Pro is a Bash and POSIX IDE with support for $@try it now!
© 2020–2024 Joachim Ansorg
Imprint
Privacy Policy
Legal