Wicked Cool Shell Scripts
Wicked Cool Shell Scripts :: shell script 009-scriptbc.sh

Shell Script 009-scriptbc.sh

#!/bin/sh

# scriptbc - wrapper for 'bc' that returns the value of a formula

if [ $1 = "-p" ] ; then
  precision=$2
  shift 2
else
  precision=2		# default
fi

bc -q -l << EOF
scale=$precision
$*
quit
EOF

exit 0

Explore The Book!
[book cover]
Table of Contents
Read Some Scripts!
Shell Script Library
Book Errata
All The Links
Read the Reviews
Talk About It
Author Bio
Buy The Book!



Other books by author Dave Taylor
Learning Unix for Mac OS X (O'Reilly & Associates)
Solaris 9 for Dummies (Wiley)
Teach Yourself Unix in 24 Hours (Sams/Macmillan)
Teach Yourself Unix System Administration in 24 Hours (Sams/Macmillan)
Creating Cool HTML 4 Web Pages (Wiley)