January 2004
Intermediate to advanced
368 pages
7h 25m
English
This script works with a variety of mathematical formulas, and an unusual input format, to translate between Fahrenheit, Celsius, and Kelvin. It's the first use of sophisticated mathematics within a script in this book, and you'll see where the experimentation in Script #9 that produced scriptbc proves a tremendous boon, as the same concept of piping an equation to bc shows up again here.
#!/bin/sh # convertatemp - Temperature conversion script that lets the user enter # a temperature in Fahrenheit, Celsius, or Kelvin and receive the # equivalent temperature in the other two units as the output. if [ $# -eq 0 ] ; then cat << EOF >&2 Usage: $0 temperature[F|C|K] where the suffix: F indicates input is ...
Read now
Unlock full access