1829023 Members
2776 Online
109986 Solutions
New Discussion

Command " $@"

 
SOLVED
Go to solution
Manuales
Super Advisor

Command " $@"

what is the meaning of $@?

Regards.
3 REPLIES 3
curt larson_1
Honored Contributor
Solution

Re: Command " $@"

it sort of depends on the shell your using.

but, in the korn shell, it stands for the expandsion of the positional parameters. ksh expands the positional parameters starting with $1, separating them with space characters.

"$@" is equivalent to "$1" "$2" up to "$n" where n is the value fo $#.

where there are no positional parameters, ksh expands "$@" to an unquoted null string

and you can not initalize or assign vaules to the variable @
Peter Nikitka
Honored Contributor

Re: Command " $@"

Hi,

the special meaning of "$@" is, that it keeps embedded spaces (or other characters of $IFS) in its usage.

myscript a 'b c' 'd e f'
will report (echo $#) three parameters.

Using a
myotherscript $*
in 'myscript' will send six parameters to 'myotherscript', while

myotherscript "$@"
will keep the original three.

mfG Peter
The Universe is a pretty big place, it's bigger than anything anyone has ever dreamed of before. So if it's just us, seems like an awful waste of space, right? Jodie Foster in "Contact"
Yogeeraj_1
Honored Contributor

Re: Command " $@"

hi manuales,

see also http://www.injunea.demon.co.uk/pages/page212.htm#15.5

for more examples on $# and $@


hope this helps too!

kind regards
yogeeraj
No person was ever honoured for what he received. Honour has been the reward for what he gave (clavin coolidge)