分页: 1 / 1

shell “$*”

发表于 : 2011-11-02 23:29
bellszhu

代码: 全选

bellszhu@bells-ThinkPad:~$ type testfunc
testfunc is a function
testfunc () 
{ 
    echo "$# parameters";
    echo Using '"$*"';
    for p in "$*";
    do
        echo "[$p]";
    done
}

执行如下:

代码: 全选

bellszhu@bells-ThinkPad:~$ IFS="|${IFS}" testfunc abc "a bc" "1 2
3"
3 parameters
Using "$*"
[abc|a bc|1 2
3]
bellszhu@bells-ThinkPad:~$ 
为什么会输出这样的结果呢??
"$*" 好像被当成了一个
特别是这个竖线| 好难理解呀。。

Re: shell “$*”

发表于 : 2011-11-02 23:44
枫叶饭团
完全无法理解

Re: shell “$*”

发表于 : 2011-11-03 11:02
eexpress
折腾带空格的,应该用$@吧。