1847227 Members
3003 Online
110263 Solutions
New Discussion

meaning of $@

 
SOLVED
Go to solution
Allanm
Super Advisor

meaning of $@

and other $ .

Thanks.
4 REPLIES 4
Pete Randall
Outstanding Contributor
Solution

Re: meaning of $@

Try "man sh-posix", in particular, look at the "Parameter Substitution" section.


Pete

Pete
TTr
Honored Contributor

Re: meaning of $@

In what context are you asking? They can take different meaning form shells and regular expressions, to vi, to senmail rules etc.
Tim Nelson
Honored Contributor

Re: meaning of $@

Inside a korn shell it means.....

gimme all the supplied command line args

a script that does this:
echo $@

Will do this when run with args
./test.ksh arg1 arg2 arg3
arg1 arg2 arg3

Peter Nikitka
Honored Contributor

Re: meaning of $@

Hi,
I want to remember the special meaning of
"$@" (in double quotes), which saves spaces contained in arguments.
Continuing and modifying Tim's example with
cat test.ksh
#!/usr/bin/ksh
for i in "$@"
do print "arg='$i'"
done

and a command line of
./test.ksh 'arg1 arg2' arg3

will lead to an output
arg='arg1 arg2'
arg='arg3'

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"