Script started on Mon Oct 1 15:37:09 2001 ############################################################ # 'iota' is an APL-inspired script I wrote to generate # the integers from 1 to n, one per line. It comes in # useful in many instances. In Linux, there is also # a command 'seq', which can so the same thing. ############################################################ lnx1 1> iota usage: iota [] lnx1 2> which iota /usr/local/bin/iota ############################################################ # 'mw' is another script which attempts to locate # the source for a script or other executable, and if # successful, displays the source. ############################################################ lnx1 3> mw iota #!/bin/sh Usage="usage: iota []" case $# in 1) n=$1; origin=1;; 2) n=$1; origin=$2;; *) echo "$Usage"; exit 1;; esac if printf "%d" $n > /dev/null 2>&1 && \ printf "%d" $n > /dev/null 2>&1 $origin; then awk 'BEGIN{for(i=0; i<'$n'; i++) printf "%d\n", i+'$origin'}' < /dev/null else echo "$Usage"; exit 1; fi ############################################################ # Sample 'iota' invocation. ############################################################ lnx1 4> iota 10 1 2 3 4 5 6 7 8 9 10 ############################################################ # Create 'first100' file. ############################################################ lnx1 5> iota 100 > first100 ############################################################ # Display first 10 lines of 'first100' using Unix 'head' # command. Note use of '!$' (last argument to previous # command). ########################################################### lnx1 6> head -10 !$ head -10 first100 1 2 3 4 5 6 7 8 9 10 ############################################################ # Display last 10 lines of 'first100' using Unix 'tail' # command. ############################################################ lnx1 7> tail -10 !$ tail -10 first100 91 92 93 94 95 96 97 98 99 100