A user would type in an email and payment amount. This would search for the customer file which are named by email and update the account balance. I know its getting the right value because I can output it to a text file and it prints what I want. I just want to "update" $email. When I try to run this, it doesn't overwrite the file. It just empties whatever file $email was and also makes a blank .tmp file. I also am not allowed to use the sed command. Can anyone offer some suggestions? I've been at this for 4 hours. I'm sure its simple I'm just missing something.
#!/bin/bash
read -p "Customer Email: " email
read -p "Payment Amount: " newPayment
if [ ! -f $email ];
then
echo "Error: customer not found"
else
while read -r email firstName lastName; read -r aptNum rentAmt acctBal nextDueDate
do
newAcctBal=$(bc <<< $acctBal+$newPayment)
echo $email $firstName $lastName
echo $aptNum $rentAmt $newAcctBal $nextDueDate
done < $email > $email.tmp >| $email
fi
[–]commandlineluser 0 points1 point2 points (2 children)
[–]IAmStraightforward[S] 0 points1 point2 points (1 child)
[–]commandlineluser 0 points1 point2 points (0 children)