$n

代表第几个参数,$1是第一个,$0是文件名

#!/bin/bash

echo $(($1 + $2))
# ./canshu.sh 12 34
46

$*

$*是把所有参数当作一个整体

$@将所有参数分开

$#是参数个数

# ./canshu.sh 11 22 33 44
33
11 22 33 44
11
22
33
44
$# is:4
#!/bin/bash

echo $(($1 + $2))

for i in "$*"
    do 
        echo $i
    done

for y in "$@"
    do 
        echo $y
    done

echo "\$# is:$#"

results matching ""

    No results matching ""