Hi all , below i am suppose to key in and enter the daily sales in to the system.
and i am suppose to get the daily total sales and the grand total sales when i ask for summary listing
below is the code that i have write.. can any one help?
the function doesnt seems to bea ble to reconise the system day and promt me a syntaxerror..
Code:
#Enter and add in the Item detail, Item Price and Quantity Purchased into the system.
add_item()
{
echo "Add Item: You will be prompted for 3 items:"
echo "- Item Description, Unit Price, Quantity Purchased -"
echo
echo -en "Item Description:"
read product
echo -en "Unit Price:"
read Unit_Price
echo -en "Quantity:"
read Quantity
Date_Purchased=$(date +"%d %b %Y")
echo "${product}:${Unit_Price}:${Quantity}:${Date_Purchased}" >> $POS
}
#i am printing out all the daily sales in a day print_dtotal
#i am printing out all the grand total sales of all days print_gtotal
summary_items()
{
print_dtotal
print_gtotal
print_dtotal | sort -f4| while read z
do
echo $z | cut -f4 -d' '
return 0
done
echo
echo -en "Press Enter to continue..."
read
}
print_dtotal()
{
count=0
grep -i : $POS | cut -d: -f4 | sort -u | while read i
do
dtotal=0
grep -i "$i" $POS | while read x
do
count=`expr $count + 1`
temp1=`echo $x | cut -d: -f2 | cut -c2-`
temp2=`echo $x | cut -d: -f3`
temp3=`calcu_m $temp1 $temp2`
dtotal=`calcu_a $dtotal $temp3`
n=`num_lines "$i"`
if [ "${n}" -eq "${count}" ]; then
echo $i" $"$dtotal
fi
done
done
}
print_gtotal()
{
gtotal=0
grep -i : $POS | while read x
do
temp1=`echo $x | cut -d: -f2 | cut -c2-`
temp2=`echo $x | cut -d: -f3`
temp3=`calcu_m $temp1 $temp2`
gtotal=`calcu_a $gtotal $temp3`
n=`num_lines "$i"`
if [ "${n}" -eq "${count}" ]; then
echo "Grand Total $"$gtotal
fi
count=`expr $count + 1`
done
}
calcu_a() # add 2 decimal numbers $1 $2
{
x1=`echo $1 | cut -d. -f1`
x2=`echo $1 | cut -d. -f2`
y1=`echo $2 | cut -d. -f1`
y2=`echo $2 | cut -d. -f2`
x1=`expr $x1 + $y1`
x2=`expr $x2 + $y2`
x3=`expr $x2 \/ 100`
x1=`expr $x1 + $x3`
x2=`expr $x2 \% 100`
echo $x1"."$x2
}
calcu_m() # multiply 2 decimal numbers $1 $2
{
x1=`echo $1 | cut -d. -f1`
x2=`echo $1 | cut -d. -f2`
y=`echo $2`
x1=`expr $x1 \* $y`
x2=`expr $x2 \* $y`
x3=`expr $x2 \/ 100`
x1=`expr $x1 + $x3`
x2=`expr $x2 \% 100`
echo $x1"."$x2
}
Hi All,
Script to meet my requirement might be simpler for UINIX experts.. :)
I need to generate an summary report in .txt file using shell script
I have Reject directory in Unix server which contains all reject files for three diff categories- Presentation, Chapter and Scene
Following... (3 Replies)
Hello,
I have 2 csv files with 4 columns each.
file1.csv
A, AA, AAA, AAAA
B, BB, BBB, BBBB
file2.csv
C, CC, CCC, CCCC
D, DD, DDD, DDDD
I would like to use shell commands (sed, awk...) to copy the content of the 2 files (2x4 columns) into a final csv template file.
Expected... (2 Replies)
Hi,
I want to calculate the total cpu usage from the sar report. Say for example,
Linux 2.6.24-21-generic (blade10) 09/10/2012
04:54:36 PM CPU %user %nice %system %iowait %steal %idle
04:54:37 PM all 0.00 0.00 0.00 0.00 ... (1 Reply)
Hello all;
I'll try an explain my dilemma as best I can. But first some background:
1- I am suppose to compare a database to itself before and after changes; basically generate audit trail report.
2- This database contains "RULES" (the id field) that we use for transmitting files.
3 - The... (0 Replies)
hey i want to print the summary or the total disk usage of the configuration files that are in the /etc directory printed in human-readable format.
i think i got somewhere right as am using wc *.conf commands but i am unsure how to use to put it in human-readable format with the wc command.
... (13 Replies)