#!/bin/bash

for name in *.fits ; do
    short=`echo $name | sed 's/\.fits//'`
    chipNum=0
    while [ $chipNum -lt 36 ] ; do
      chipName=`printf 'ccd%02d' $chipNum`
      imcopy $name\[$chipName\] $short.$chipName.fits
      chipNum=$(( $chipNum + 1 ))
    done
done
    

