What is the difference between `$ *` and `$ @` in Bash


This question already has an answer here:

I always use [email protected] when I want all arguments of bash function but recently I just found that $* also works in the same way, and it also can use as array index.

My question is What is difference between $* an [email protected] in Bash? and which one should I prefer?

The Bash manual is quite clear on this topic:

  • $*

    All of the positional parameters, seen as a single word.

    Note: $* must be quoted.

  • [email protected]

    Same as $*, but each parameter is a quoted string, that is, the parameters are passed on intact, without interpretation or expansion. This means, among other things, that each parameter in the argument list is seen as a separate word.

    Note: Of course, [email protected] should be quoted.