I'm trying to write a simple script to figure pay with overtime...I got the first part to work, but I can't seem to get the second if statement's syntax right...I want it to take the 40 hours times 10 dollars, but then i want whatever is left over (like 7 of 47 hours) and take that times 15 dollars and then add the two figures...here's what I've got:
#!/bin/bash
# Script for figuring pay with overtime
# 5/28/08
hours=$1
normal=10
over=15
ntimepay=400
time=40
if [ $hours -le 40 ]
then
pay=$[$hours*$normal]
else
if [ $hours -gt 40 ]
then
pay=$[expr $ntimepay + [$hours-$time]*$over]
fi
fi
echo "Total pay is $pay"
echo "done"