2

array and functions

view story
linux-howto

http://www.unix.com – Hi Guys! I need to solve this. I want an array to be created by a certain calculation for which I created a function. Now this array is not getting created. See script below I want array b to be the factorial value of array element a. Help is needed. Thanks! Code: #!/bin/bash . /home/adhaka/scripts/fun echo "Number of factorials:" read h for (( i = 0; $i < h; i++ )) do echo "Enter the factor $i:" read d a[$i]=$d b[$i]=$(fun $d) done echo ${a[*]} echo ${b[*]} fun() { j=`expr 1 + $1` z=1 f=0 for (( i = 1; $i < $j; i++ )) do f=`expr $j - $i` z=`expr $z \* $f` d (HowTos)