shell - 参数传递
#!/bin/bash
echo $0
echo $1
echo ${10}
echo ${11}# ./a.sh a b c d e f g h i j k
./a.sh
a
j
k#!/bin/bash
name=""
age=""
for (( i=1; i<=$#; i++ )); do
eval opt='$'{${i}}
case ${opt} in
--name)
let "i++"
eval name='$'{${i}}
;;
--age)
let "i++"
eval age='$'{${i}}
;;
*)
echo "Error : invalid opt ${opt}"
exit 1
esac
echo "Name is : ${name}"
echo "Age is : ${age}"附录: $* vs $@
$* vs $@Last updated