Commit 80558c9b authored by vagrant's avatar vagrant

problem 5 solved, but total still needed

parent fac70d59
#!/bin/bash
timesheet="$(pwd)/timesheet.csv"
timesheet=$1
#sort timesheet by customer
#sum of each customer
currentCustomer=""
sum=0
total=0
echo "Customer : Hours"
#infinite loop rn
sort -t"," -k5 $timeshet | while read -r line
sort -t"," -k5 $timesheet | while read -r line
do
customer=$(echo $line | cut -d"," -f5)
billable=$(echo $line | cut -d"," -f7)
hours=$(echo $line | cut -d"," -f8)
echo $customer
if [$customer != $currentCustomer]
if [ "$customer" != "$currentCustomer" ]
then
#echo $currentCustomer
#echo $sum
currentcustomer=$customer
echo "$currentCustomer : $sum"
total=$(($total + $sum))
currentCustomer="$customer"
sum=0
fi
if [$billable == "Y"]
if [ "$billable" == "Y" ]
then
sum=$((sum + hours))
sum=$(($sum + $hours))
fi
done
#echo "Total : $total"
#final print sum
echo $currentCustomer
echo $sum
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment