#!/usr/bin/env tsh : : tsh - " Force sh(1), csh(1), and other shells to exit w/ error! " <'' ;;; : : " @(#)$Id: 05647d25888c73cc5c289ca966068b26245bf1c3 $ " : : " The author of this file, J.A. Neitzel , " : " hereby grants it to the public domain. " : : : " This command file demonstrates using `shift' to control " : " loop iteration, counting from 1 to 20 (by ones, by evens, " : " and by odds) in 3 separate shell loops. " : : " usage: counts " : : 1 tsh - 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ; echo ; echo ; goto 2 echo -n 'Count (1 -> 20): ' : Count echo -n \ $1 shift if X$1 = X exit goto Count : 2 tsh - 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ; echo ; echo ; goto 3 echo -n 'Evens (1 -> 20): ' shift : Evens echo -n \ $1 if X$2 = X exit : " Skip the next odd number... " ; shift ; shift ; goto Evens : 3 tsh - 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ; echo echo -n ' Odds (1 -> 20): ' : Odds echo -n \ $1 if X$3 = X exit : " Skip the next even number... " ; shift ; shift ; goto Odds