I need a correction in my shell syntax (given below)
cat $dfn | gawk
'{for (i = 1; i <= NF; i += 1)
{printf "%f\t", ((($i / $tag) / $bn ) */ 1000000000);}
printf "\n"}'>fn
where $dfn
is the file name $tag
and $bn
hold a value. and fn
is the the file where output is being directed.
Note: what this line does, it takes a file name ( which is of n by m dimension and contains a value in each cell) divides each 开发者_运维知识库value in the cell by the value in $tag
variable answer of this is divided again by the value in $bn
and finally after all division operations are performed the value is multiplied by 1 billion.
Thank you in advance.
The variables $tag
and $bn
are referring to fields in the lines. I'm assuming you actually want them to be environment variables. Pass them as variables to awk:
cat $dfn |
gawk -v tag="$tag" -v bn="$bn" '{
for (i = 1; i <= NF; i += 1) {
printf "%f\t", ((($i / tag) / bn ) * 1000000000)
}
printf "\n"
}'>fn
Edit: Also fix the multiplication as indicated by Raghuram.
I think you shuld change the /* to * when you mutiply the value by 1 Billion.
精彩评论