I found a few interesting DIY wood working projects on the interwebs and because the measurements were in inches I wrote a simple sh script to convert these to millimeters and centimeters.
Code:
#!/bin/sh
# use 'bc(1)', the multiprecision calculator to convert inches to mm and cm
INCH='25.4' # millimeter (mm)
PRECISION=4 # nr of fractional digits
VALUE=1
cat <<END
You can enter values like '1 1/4' or '2 3/8' inch as '1+1/4' and '2+3/8'
-----------------------
Nr of inches: 1/8
1/8 inch = 3.1750 mm or .3175 cm
Nr of inches: 1+1/4
1+1/4 inch = 31.7500 mm or 3.1750 cm
-----------------------
Press CNTRL-C to exit.
END
while true ; do
printf "\nNr of inches: "
read VALUE
MM=$( echo "scale = ${PRECISION} ; ( ${VALUE} ) * ${INCH}" | bc )
CM=$( echo "scale = ${PRECISION} ; ${MM} / 10" | bc )
echo "${VALUE} inch = ${MM} mm or ${CM} cm"
done
Example where I convert the size of a 2 by 4" and the 1/16" holes to drill in a 3/4" PVC irrigation pipe:
Code:
$ ./inch2milli.sh
You can enter values like '1 1/4' or '2 3/8' inch as '1+1/4' and '2+3/8'
-----------------------
Nr of inches: 1/8
1/8 inch = 3.1750 mm or .3175 cm
Nr of inches: 1+1/4
1+1/4 inch = 31.7500 mm or 3.1750 cm
-----------------------
Press CNTRL-C to exit.
Nr of inches: 2
2 inch = 50.8 mm or 5.0800 cm
Nr of inches: 4
4 inch = 101.6 mm or 10.1600 cm
Nr of inches: 1/16
1/16 inch = 1.5875 mm or .1587 cm
Nr of inches: 3/4
3/4 inch = 19.0500 mm or 1.9050 cm
Nr of inches: ^C$