#!/bin/bash

for name in *.fits ; do
    short=`echo $name | sed 's/\.fits//'`
    for chipNum in 12 13 14 21 22 23; do
      chipName=`printf 'ccd%02d' $chipNum`
      imcopy $name\[$chipName\] $short.$chipName.fits
    done
done
    

