Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

What is the difference between $@ and $* ? 1

Status
Not open for further replies.

signalsys

Technical User
Sep 5, 2005
44
0
0
CN
Thx in advance
 
Hi signalsys,


Code:
$* 
contains all of the arguments in a single string, with one space separating them. 
$@ 
similar to $*, but if used in quotes, it effectively quotes each argument and keeps them separate. If any argument contains whitespace, the distinction is important. 
e.g. if the argument list is: a1 a2 "a3 which contains spaces" a4
then: $1=a1, $2=a2, $3=a3 which contains spaces, $4=a4
and: $*=a1 a2 a3 which contains spaces a4
and: "$@"="a1" "a2" "a3 which contains spaces" "a4"

Only using the form "$@" preserves quoted arguments. If the arguments are being passed from the script directly to some other program, it may make a big difference to the meaning.

Regards,
Khalid
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top