Hi people
I'm learning shell scripting using bash and I want to generate 4 floating point number with 5 decimal places and write them to a file and a variable. I've done all this except the $RAMDOM enviroment variable does not generate a float number but a integrer.
I hope you could explain why to lead me to a solution.
Thnak you all in advance.
PS: script so far
#!/bin/bash
#: Title : randomFloats
#: Date : 2011-03-27
#: Author : pharaoh
#: Version : 1.0
#: Discription : Generate a 4 float numbers with 5 decimal places and write them to a file and a variable
listFloats=0.0
for i in $(seq 0 3)
do
aux=$[($RANDOM % 15000)]
printf -v aux "%.5f" ${aux}
#In the first iteration it just set the variable, in the others it append
if [ ${i} -eq 0 ]
then
listFloats=${aux}
printf ${aux} > randomFloats.txt
else
listFloats="${listFloats} ${aux}"
printf ${aux} >> randomFloats.txt
fi
done
printf "%s\n" ${listFloats}