1# Towers of Hanoi in bash 2# 3# cribbed from the ksh93 book, example from exercises on page 85 4# 5# Chet Ramey 6# chet@po.cwru.edu 7 8hanoi() # n from to spare 9{ 10 typeset -i nm1=$1-1 11 ((nm1>0)) && hanoi $nm1 $2 $4 $3 12 echo "Move disc $2 to $3" 13 ((nm1>0)) && hanoi $nm1 $4 $3 $2 14} 15 16case $1 in 17[1-9]) 18 hanoi $1 1 2 3;; 19*) echo "${0##*/}: Argument must be from 1 to 9" 20 exit 1;; 21esac 22