字符串数组传入函数
2021-08-25 本文已影响0人
Jesson3264
#!/bin/bash
str=(
"zhangsan" "29"
"lisi" "30"
)
array=($str)
function test()
{
echo "param" $@
array=(`echo "$@"`)
for i in $array
do
echo $i
done
len=${#array[@]}
echo $len
for ((i=0;i<len/2;i++))
do
echo ${array[$i * 2]} "-- " ${array[$i * 2 + 1]}
done
}
test "${str[*]}"