Adam Sznajder Adam Sznajder - 1 year ago 59
Bash Question

What's the difference between $@ and $*?

What's the difference between

? Why they have the same value but
are different when I set

Answer Source

The difference between $@ and $*: Unquoted (don't do this!), none at all: both equal $1 $2 .... With double quotes, $@ expands each element as an argument: $1 $2 ..., while $* expands to all elements merged into one argument: $1c$2c... (where c is the first character of IFS). You almost always want $@. The same goes for arrays: ${myarray[@]}

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download