special variable $@ and $*
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. Thanks, Kaushal -- ubuntu-users mailing list ubuntu-users@lists.ubuntu.com Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users |
special variable $@ and $*
> 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. ./script "name with spaces" For the above $* is expanded to three arguments, "name", "with", and "spaces" $# is expanded to one argument, "name with spaces" -- ubuntu-users mailing list ubuntu-users@lists.ubuntu.com Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users |
special variable $@ and $*
On Sat, Dec 5, 2009 at 2:33 PM, Tom H <tomh0665@gmail.com> wrote:
>> 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. > > ./script "name with spaces" > > For the above > $* is expanded to three arguments, "name", "with", and "spaces" > $# is expanded to one argument, "name with spaces" > Hi Tom, #!/bin/bash echo "alice: $*" echo "alice: $@" echo "$@: $1 $2" echo "$# arguments" The above script name is test.sh hosttest ~ # ./test.sh alice in wonderland alice: alice in wonderland alice: alice in wonderland alice in wonderland: alice in 3 arguments Still not clear as per the above output. both prints same. Please guide with some example or in context with my bash snippet. Thanks and Regards, Kaushal -- ubuntu-users mailing list ubuntu-users@lists.ubuntu.com Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users |
special variable $@ and $*
2009/12/5 Kaushal Shriyan <kaushalshriyan@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 -- ubuntu-users mailing list ubuntu-users@lists.ubuntu.com Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users |
| All times are GMT. The time now is 01:24 AM. |
VBulletin, Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.