#!/bin/bash

find . -name "*.fits" -exec gzip -v {} \;

for f in *.fits.gz
do 
  s="${f}_stats.txt"
  m="${f}_meta.txt"
  if [ ! -e "${s}" ]
  then 
	  stilts tcat omode="stats" in="${f}" > "${s}"
		echo $s generated
	fi
  if [ ! -e "${m}" ]
  then
    stilts tcat omode="meta" in="${f}" > "${m}"
		echo $m generated
  fi
done
