|
区别:@@*
- 相同点:都是引用所有参数
- 不同点:只有在双引号中体现出来。假设在脚本运行时写了三个参数(分别存储在112 3)则"3)则"*" 等价于 “112 3"(传递了一个参数);而“3"(传递了一个参数);而“@" 等价于 "1""1""2" "$3"(传递了三个参数)
例子一
##dels.shecho "number:$#" echo "scname:$0" echo "first :$1" echo "second:$2" echo "argume:[email protected]" echo "show parm list:$*" echo "show process id:$$" echo "show precomm stat: $?"
执行结果
1 2 3 4 5 6 7 8 9 |
|
例子二
#!/bin/sh num=$# name=$0 echo "number:$num" echo "scname:$name" echo $0 echo $1 echo $2 for ((i=0; i<$num; i++)) do echo "$i" done echo "argume:[email protected]" for key in [email protected] do echo $key done echo "-----------------" for key in "[email protected]" do echo $key done echo "-----------------------------" for key2 in $* do echo $key2 done echo "-----------------" for key2 in "$*" do echo $key2 done echo "show process id:$$" cho echo "show precomm stat: $?"
执行结果
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
|
问题:
echo #0 #1 能不能用 $i 表示呢?
时间: 2024-10-03 22:48:02