#函数变量 #!/usr/bin/bash num=(1 2 3) array(){ local factorial=1 for i in "$@" do factorial=$[factorial * $i] echo "$factorial" done } array ${num[*]} ################################################################# #!/usr/bin/bash num=(1 3 4) array(){ local newarray=(`echo $*`) local i for((i=0;i<$#;i++)) do outarray[$i]=$((${newarray[$i]}*5)) done echo "${outarray[*]}" } result=`array ${num[*]}` #子shell中执行 echo ${result[*]}
标签:bin,变量,factorial,echo,num,array,local,函数 From: https://www.cnblogs.com/smatter/p/16943036.html