What does $@ mean as a bash script function parameter

bashshell

What does $@ mean as a bash script function parameter?

Example:

function foo()
{
    echo "$@" 1>&2;
}

Best Answer

The $@ variable expands to all the parameters used when calling the function, so

function foo()
{
    echo "$@"
}

foo 1 2 3

would display 1 2 3. If not used inside a function, it specifies all parameters used when calling the script. See the bash manual page for more info.

Related Question