Can anyone please tell me how do i define the variable as decimal.
Below is my script. After division i get a whole number where as i want to see the decimal places also..
TABLEAVG=`expr ${TABLECHARS}/${TABLELINES} | bc`
EG: if TABLECHARS= 1280 and TABLELINES=44 the
O/P is 29.0909
I want the decimal to be diplayed on the screen..whereas what i get now is 29
I want the output with the decimal places to be displayed
But i have a problem...
I have given an if statment stating that if its whole number output the "TABLEAVG"
else
value with decimal...
if [ $TABLEAVG == 29 ]
then
echo "The file is good with count of comma per line : $TABLEAVG"
else
echo "The file is corrupt with commas : $TABLEAVG"
fi
If the output is 29, it displays 29.00 because i have given the sacle..is there any workaround for this..
I need both..
Eg: as per the script if the tablechar=58 and the tablelines=2 the output after division is 29(tableavg)
now, in the IF statment
if [ $TABLEAVG == 29 ]
then
echo "The file is good with count of comma per line without any decimal point : $TABLEAVG"
else
echo "The file is corrupt with commas having decimal values : $TABLEAVG"
fi
i dont want the decimal places if the is it 29.000(the zeros have to be eliminated), where as if the o/p is 29.09 i want that ouput with decimal values..
thanks in advance
and say for eg: if the output is with