Hi. I do not know how to compare numbers and need help. In my script I have to figure the MAX, MIN, & Avg. Sales amounts.
Please help me.
In the code, "transaction" is a counter.
#!/bin/bash
clear
transaction=0
sales=0
total=0
while test $sales
do
echo -e "Enter sales price: \c"
read sales
let transaction=$transaction+1
let total=total+sales
done
echo "Number of Transactions :" $transaction
echo "Total Sales:" $total
if test $total -lt 100
then
echo " Sorry, we do not take credit cards for sales less than $100. "
fi
I didn't have bash in my system but i hope this might do what u were trying to do...
#!/bin/sh
clear
total=0
transaction=0
ans="Y"
while [[ $ans = "Y" ]]
do
echo "Enter sales price: \c"
read sales
transaction=`expr $transaction + 1`
total=`expr $total + $sales`
echo "Do you want to add transaction(Y/N): \c"
read ans
done
echo "Number of Transactions :" $transaction
echo "Total Sales:" $total
if [[ $total -lt 100 ]]
then
echo " Sorry, we do not take credit cards for sales less than 100. "
fi
Hi.
I've tried to figure out this error message but no luck. This code was sent in by Frans.
When I enter the Sales Price I get this msg:
"./ss: line 11: 2: command not found"
Transactions :
Total Sales :
max : 0
min : 0
./ss: line 21: total/transaction: division by 0 (error token is "transaction")
./ss: line 22: [: -lt unary oprator expected
I don't understand why it is complaining about "command not found".
Thanks Frans.
That worked just great, but my old nemesis is here: unary operator expected.
Line 14: [: -eq: unary operator expected ]
Thanks so much for your help.
Ccccc
Thanks Frans. Thanks Franklin52.
This was really a baptism in "unary operator expected" and "integer expression expected". Finally the light came on AND it was not a train at the end of the tunnel. (hahahahahahaha...)