special variable $@ and $*
Kaushal Shriyan
kaushalshriyan at gmail.com
Sat Dec 5 09:16:49 UTC 2009
On Sat, Dec 5, 2009 at 2:33 PM, Tom H <tomh0665 at 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
More information about the ubuntu-users
mailing list