#!/bin/sh #this program calculates the pound of toxic emissions emitted by a typical #automobile, from the number of trips (cold starts) and miles (averaging for #traveling at 25 mph and 55 mph) given. based on an algorithym by patrick #goebel of global cycling org (velonet). #peter chen, 1995 MILES= TRIPS= PRECISION= ciao() { echo "usage: $0 -m miles -t trips [-p precision]" >&2 exit 1 } while getopts m:t:p: i do case $i in m) MILES=$OPTARG;; t) TRIPS=$OPTARG;; p) PRECISION=".$OPTARG";; ?) ciao;; esac done shift `expr $OPTIND - 1` [ -z "$MILES" -o -z "$TRIPS" ] && ciao awk "END{printf\"%${PRECISION}f\n\",($TRIPS*52.84+$MILES*5.955)/454}" /dev/null