while loop in awk function - syntax problem
I am having an issue getting the correct syntax right when I use a while loop inside an awk function. I am using ksh to basically multiply series of numbers that I have generated from a while loop with another number.
The following part of the script is where I encounter problems:
var=4
i=1
while ((i <= $var))
do
answer[i]=$(awk BEGIN'{print '$number[i]'*0.0174533}')
let i=i+1
done
The $number[i] variable has already been identified beforehand and works fine.
The error I am getting is as follows:
syntax error The source line is 1.
The error context is
BEGIN{print >>> [ <<<
awk: The statement cannot be correctly parsed.
The square brackets [ ] seem to be the issue but I have tried using a few different alternatives but nothing seems to work. Can anyone please suggest a way of making the above awk statement work? It would be much appreciated.
|