Commit 80558c9b authored by vagrant's avatar vagrant

problem 5 solved, but total still needed

parent fac70d59
#!/bin/bash #!/bin/bash
timesheet="$(pwd)/timesheet.csv" timesheet=$1
#sort timesheet by customer #sort timesheet by customer
#sum of each customer #sum of each customer
currentCustomer="" currentCustomer=""
sum=0 sum=0
total=0
echo "Customer : Hours"
#infinite loop rn sort -t"," -k5 $timesheet | while read -r line
sort -t"," -k5 $timeshet | while read -r line
do do
customer=$(echo $line | cut -d"," -f5) customer=$(echo $line | cut -d"," -f5)
billable=$(echo $line | cut -d"," -f7) billable=$(echo $line | cut -d"," -f7)
hours=$(echo $line | cut -d"," -f8) hours=$(echo $line | cut -d"," -f8)
echo $customer
if [$customer != $currentCustomer] if [ "$customer" != "$currentCustomer" ]
then then
#echo $currentCustomer echo "$currentCustomer : $sum"
#echo $sum total=$(($total + $sum))
currentcustomer=$customer currentCustomer="$customer"
sum=0 sum=0
fi fi
if [$billable == "Y"] if [ "$billable" == "Y" ]
then then
sum=$((sum + hours)) sum=$(($sum + $hours))
fi fi
done 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