簡単なアカウント スクリプトを bash で作成しましたが、浮動小数点値を表示する標準的な方法がわかりませんでした。これは awk を使用した最適なソリューションですか? 残高も 0.00 を出力していますが、何かを含めるのを忘れていませんか?
#!/bin/bash
function printBalance()
{
echo | awk 'BEGIN { printf "\nCurrent balance: %.2f\n", balance }'
sleep 1
}
function makeWithdraw()
{
echo -en "\nWithdraw an amount: "
read deposit
if [ "$withdraw" -gt "$balance" ]; then
echo -en "\nInsufficient funds"
sleep 1
else
balance=$(( balance - withdraw ))
fi
}
balance=$((RANDOM%100+1))
# code continues...