1829603 Members
1874 Online
109992 Solutions
New Discussion

Using $@

 
SOLVED
Go to solution
Manuales
Super Advisor

Using $@

Hi, what is the meaning of: $@ ?

thanks
2 REPLIES 2
Nitin Kumar Gupta
Trusted Contributor
Solution

Re: Using $@

To tell about $@ I am telling two commands which is looking like similar but with little bit difference.

$* : Collectively references all the positional parameters as $1, $2, ...

$@ : Same as $*, except when double-quoted ("$@") collectively references all the positional parameters as "$1", "$2", ...

Remember in both the cases you cannot reassign the Parameter values.

Regards
Nitin
spex
Honored Contributor

Re: Using $@

Hi Manuales,

From sh-posix(1):

The meanings of $* and $@ are identical when not quoted or when used
as a parameter assignment value or as a file name. However, when used
as a command argument, "$*" is equivalent to "$1d$2d...", whereas "$@"
is equivalent to "$1"d"$2"d... (where d is the first character of
IFS), The special meaning of keywords or aliases can be removed by quoting
any character of the name. The recognition of function names or
special command names cannot be altered by quoting them.

PCS