test.sh 1 2 3
$* 为"1 2 3"
$@ 为"1" "2" "3"
$# 为3,参数数量
#!/bin/bash my_fun(){ echo "$#" } echo "$@" echo "$#" echo "$(my_fun "$@")" echo "$(my_fun "$#")"
test.sh 1 2 3 2输出
1 2 3 2
4
4
1
test.sh 1 2 3
$* 为"1 2 3"
$@ 为"1" "2" "3"
$# 为3,参数数量
#!/bin/bash my_fun(){ echo "$#" } echo "$@" echo "$#" echo "$(my_fun "$@")" echo "$(my_fun "$#")"
test.sh 1 2 3 2输出
1 2 3 2
4
4
1