Name

loop — generate numerical indices for shell loops, etc.

Synopsis

loop [-c] start finish [increment]

DESCRIPTION

loop generates a sequence of numbers between start and finish inclusive, one per line, on stdout. This is mostly useful for driving loops when writing Shell programs sh(1). The default increment is +1 when start<finish, and -1 when start>finish. An optional increment may be specified. If increment is zero, then the start value will be generated continuously.

Both floating point and integer arguments can be used. On integer arguments, if leading zeros are specified, they will be preserved on output. This is useful for generating sequences of file names which are numbered with leading zeros.

-c is used for character (char) looping.

EXAMPLES



for i in `loop 10 30 5`

do

  echo $i

done

will display the values 10, 15, 20, 25, 30 .



for i in `loop 008 005`

do

  echo $i

done

will display the values 008, 007, 006, 005 .



for i in `loop 0.1 2.9 0.5`

do

  echo $i

done

will display the values 0.1, 0.6, 1.1, 1.6, 2.1, 2.6 .

BUGS

This program just scratches the surface. The shells could benefit from a greater ability to perform math. Limitless opportunities for extensions exist, but this simple version is adequate for most shell scripts dealing with sequences of images, etc.

AUTHOR

BRL-CAD Team

COPYRIGHT

This software is Copyright (c) 1986-2020 by the United States Government as represented by U.S. Army Research Laboratory.

BUG REPORTS

Reports of bugs or problems should be submitted via electronic mail to