special variable $@ and $*
Loïc Grenié
loic.grenie at gmail.com
Sat Dec 5 09:20:49 UTC 2009
2009/12/5 Kaushal Shriyan <kaushalshriyan at gmail.com>:
> Hi,
>
> http://tldp.org/LDP/abs/html/internalvariables.html#APPREF
>
> I did not understand the difference between $@ and $* special variable.
> Please explain me with an example.
If your script is script:
#!/bin/sh
ls $*
ls $@
ls "$*"
ls "$@"
then
script first "second long" and third
would call ls with respectively:
ls first second long and third (5 args)
ls first second long and third (5 args)
ls "first second long and third" (1 arg)
ls first "second long" and third (4 args -- the same you gave to the script)
Hope this helps,
Loïc
More information about the ubuntu-users
mailing list