#!/bin/bash my_fun() { echo "$#" } echo 'the number of parameter in "$@" is '$(my_fun "$@") echo 'the number of parameter in "$*" is '$(my_fun "$*")執行:./my.sh p1 "p2 p3" p4后返回:the number of parameter in "$@" is 3the number of parameter in "$*" is 1$*表示所有這些參數都被雙引號引住。若一個腳本接收兩個參數,$*等于$1$2$@表示所有這些參數都分別被雙引號引住,若一個腳本接收到兩個參數,$@等價于$1$2$#表示提供給腳本的參數號這里怎么看出$*和$@的區別呢?為什么執行結果是3和1呢?這里$#又是什么意思呢?
添加回答
舉報
0/150
提交
取消