27.08.2015 Views

Advanced Bash−Scripting Guide

Advanced Bash-Scripting Guide - Nicku.org

Advanced Bash-Scripting Guide - Nicku.org

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>Advanced</strong> <strong>Bash−Scripting</strong> <strong>Guide</strong><br />

interest_rate=$(echo "scale=9; $interest_r/12 + 1.0" | bc)<br />

top=$(echo "scale=9; $principal*$interest_rate^$term" | bc)<br />

echo; echo "Please be patient. This may take a while."<br />

let "months = $term − 1"<br />

# ====================================================================<br />

for ((x=$months; x > 0; x−−))<br />

do<br />

bot=$(echo "scale=9; $interest_rate^$x" | bc)<br />

bottom=$(echo "scale=9; $bottom+$bot" | bc)<br />

# bottom = $(($bottom + $bot"))<br />

done<br />

# −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−<br />

# Rick Boivie pointed out a more efficient implementation<br />

#+ of the above loop, which decreases computation time by 2/3.<br />

# for ((x=1; x

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!