diff --git a/assignmentFive.sh b/assignmentFive.sh old mode 100644 new mode 100755 index 475b7f89260e90d46d9fe745befdf1eb126ab5c4..6ea08be896723f44def0fd20037c111cb1b02b4c --- a/assignmentFive.sh +++ b/assignmentFive.sh @@ -1,3 +1,16 @@ #!/bin/bash +echo "Customer: Hours" +awk -F, '{ + arr[$5]+=$8 + } + END{ + for(key in arr) print key , arr[key]}' timesheet.csv | sort -u -cat timesheet.csv | awk -F"," ' {if (($7 == "Y")) print; } ' | cut -d ',' -f5,7-8 \ No newline at end of file +declare -i totalhours=0 +while read LINE +do + billFlag=$(echo $LINE | awk -F, '{print $7}') + hours=$(echo $LINE | awk -F, '{print $8}') + [[ $billFlag == "Y" ]] && totalhours=$(( $totalhours + $hours )) +done < ./timesheet.csv +echo "Total: $totalhours" \ No newline at end of file