help with fractions


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting help with fractions
# 1  
Old 07-09-2008
help with fractions

Smilie
please can anyone help me with the thread below. I keep getting parse errors, illegal character M G R.this is a portion of the script:
ckk=.20
Ded=.10
basic_sal=90000
Allowances=echo "$chk" * "$basic_sal" | bc
Deductions=echo "$Ded" * "$basic_sal" | bc
echo "Gross_salary=`expr($basic_sal + $Allowances) - $Deductions` "
# 2  
Old 07-09-2008
Try:
Allowances=`echo $chk "*" $basic_sal | bc`

those are backquotes, not single quotes.
# 3  
Old 07-09-2008
Why don't use bc to the end?
Code:
ckk=.20
Ded=.10
basic_sal=90000
Allowances=`echo "$chk * $basic_sal" | bc`
Deductions=`echo "$Ded * $basic_sal" | bc`
echo Gross_salary=`echo $basic_sal + $Allowances - $Deductions | bc`

always check for typo.
Login or Register to Ask a Question

Previous Thread | Next Thread

2 More Discussions You Might Find Interesting

1. Linux

Multiplication with Fractions

Hello there, how do i multiply a fraction and a whole number? Example 20% of 50,000. I had gotten 0.2 using the following: chk=echo 20 100 | awk `{print $1/$2}` echo $chk $chk \* 50000 displays the error: non-numeric expression. (1 Reply)
Discussion started by: alby
1 Replies

2. Shell Programming and Scripting

How to display fractions of a second in UNIX

How can I display fraction of a second using Date command? (2 Replies)
Discussion started by: GNMIKE
2 Replies
Login or Register to Ask a Question