#!/bin/csh -f
#
# "copyup HELLO- .dat 5 20 3" will "copy up in namespace"
#  the files HELLO-5.dat to HELLO-20.dat inclusive by 3
#  (i.e., to HELLO-8.dat to HELLO-23.dat inclusive respectively!).
#
# [NOTE: in this case HELLO-5.dat to HELLO-7.dat would be left untouched.]
#
set progname = `basename $0`

if ($#argv != 5) then
  errecho "usage: $progname <prefix> <suffix> <oldmin> <oldmax> <shift>"
  exit 1
endif

set prefix = "$1"
set suffix = "$2"
@   oldmin = $3
@   oldmax = $4
@   shift  = $5

if ($oldmin > $oldmax || $shift <= 0) then
  errecho "${progname}: silly numerical arguments\!"
  exit 1
endif

@ oldposn = $oldmax
@ newposn = $oldposn + $shift

while ($oldposn >= $oldmin)
  cp -p "$prefix$oldposn$suffix" "$prefix$newposn$suffix"
  @ oldposn--
  @ newposn--
end #while
