#! /bin/csh -fe

if ( ( $#argv < 2 ) || ( $#argv > 3 ) ) then
  echo "usage: count <from> <to> [ <step> ]"
  exit 1
endif

set from = "$1"
set to = "$2"
if ( $#argv == 3 ) then
  set step = "$3"
else
  set step = 1
endif

set mask = "`echo $from | tr '0-9' '.'`"
@ from = 10000000 + $from
@ to   = 10000000 + $to

while ( $from <= $to )
  echo "$from" | sed -e 's/^.*\('${mask}'\)/\1/'
  @ from = $from + $step
end
