#!/bin/bash -x ANG=` expr $1 / 360 \* 3 ` # Make sure that the angle of change is a divisor of 360 if [ $ANG -lt 3 ]; then ANG=3 elif [ $ANG -gt 3 ] && [ $ANG -lt 6 ]; then ANG=6 elif [ $ANG -gt 6 ] && [ $ANG -lt 9 ]; then ANG=9 elif [ $ANG -gt 9 ] && [ $ANG -lt 12 ]; then ANG=12 elif [ $ANG -gt 12 ]; then ANG=15 fi echo $ANG