-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuser_alias
More file actions
39 lines (38 loc) · 1.01 KB
/
user_alias
File metadata and controls
39 lines (38 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
alias makeTransaction='
curbal=$(cat $HOME/Current_Balance.txt);
echo "Welcome to Omega Bank";
echo "Your current balance is: $curbal";
echo "Do you wish to Withdraw(w) or Deposit(d)";
read action;
if [ "$action" == "w" ];
then
echo "Enter amount to withdraw";
read amount;
if (( $(echo "$amount > 0" | bc -l) ));
then
bal_left=$(echo "scale=2; $curbal-$amount" | bc);
if (( $(echo "$curbal > $amount" | bc -l) ));
then
echo $bal_left > $HOME/Current_Balance.txt;
echo "$USER -$amount $(date +%F) $(date +%T)" >> $HOME/Transaction_History.txt;
else
echo "Insufficient balance";
fi;
else
echo "Enter positive amount";
fi;
elif [ "$action" == "d" ];
then
echo "Enter amount to deposit";
read amount;
bal_left=$(echo "scale=2; $curbal+$amount" | bc);
if (( $(echo "$amount > 0" | bc -l) ));
then
echo $bal_left > $HOME/Current_Balance.txt;
echo "$USER +$amount $(date +%F) $(date +%T)" >> $HOME/Transaction_History.txt;
else
echo "Enter positive amount";
fi;
else
echo "Invalid option";
fi;'