9) $@ 與 $* 差在哪?

发表于:2007-05-26来源:作者:点击数: 标签:
#!/bin/bash my_fun() { echo ' inside function is ' echo ' inside function is ' echo ' inside function is ' } echo ' outside function is ' echo ' outside function is ' echo ' outside function is ' my_fun fp1 fp2 fp3 chmod +x my.sh ./my.sh p

#!/bin/bash

my_fun() {
    echo ' inside function is '
    echo ' inside function is '
    echo ' inside function is '
}

echo ' outside function is '
echo ' outside function is '
echo ' outside function is '

my_fun fp1 "fp2 fp3"

chmod +x my.sh
./my.sh p1 "p2 p3"
outside function is ./my.sh
outside function is p1
outside function is p2 p3
inside function is ./my.sh
inside function is fp1
inside function is fp2 fp3

 $@ 與 $* 差在哪了

代码:
#!/bin/bash

my_fun() {
    echo "$#"
}

echo 'the number of parameter in "$@" is '$(my_fun "$@")
echo 'the number of parameter in "$*" is '$(my_fun "$*")

原文转自:http://www.ltesting.net