Quote: http://www.study-area.org/tips/shell_13q.txt

#!/bin/bash

my_fun() {
echo “$#”
}

echo ‘the number of parameter in “$@” is ‘$(my_fun “$@”)
echo ‘the number of parameter in “$*” is ‘$(my_fun “$*”)

sh script.sh

the number of parameter in “$@” is 0
the number of parameter in “$*” is 1

sh script.sh  1 2 3

the number of parameter in “$@” is 3
the number of parameter in “$*” is 1

sh script.sh 1 “2 3”

the number of parameter in “$@” is 2
the number of parameter in “$*” is 1

 

Related posts 相關文章

作者

留言

撰寫回覆或留言

發佈留言必須填寫的電子郵件地址不會公開。