#!/bin/ksh # # function KeyVal { typeset IN_FILE=${1} typeset KEYWORD=${2} typeset key_value=`dd if=${IN_FILE} ibs=2880 count=20 obs=80 cbs=80 conv=unblock 2>>/dev/null | $(whence egrep) -e "^${KEYWORD}" | cut -b9-80| awk '{ init_sub=index($0,"=") init_quote=index($0,"'\''") if (init_quote == 0) init_quote=init_sub else end_quote=index(substr($0,init_quote+1),"'\''") if (end_quote == 0) end_quote=80 len_sub=end_quote-init_quote print substr($0,init_quote+1)}' | awk '{print $1}' | sed -e s/\'//g` echo ${key_value} } # echo "images " >> corr_$$.cl # # Next means the the script works on all files of the current dir if [[ $# -le 0 || $# -gt 1 ]] then print " Usage $0: " exit 0 fi # # # # check if the files exists # if [[ ! -r ${1} ]] then print " file ${1} doesn't exist" exit 0 fi # cat $1 | \ while read f; do # if [[ ! -r ${f} ]] then echo " Failed with file: " ${f} continue fi # # typeset filter="" # filter=`KeyVal ${f} "HIERARCH ESO INS FILT NAME"` # if [[ -z ${filter} ]] then filter="__UNKNWOWN__" fi # # # # header update { echo 'hedit '${f}[0]' FILTER '${filter}' add+ ver- show+ up+ del-' } >> corr_$$.cl # done # echo echo " the Iraf script to update headers is:" echo "\n\t\t" corr_$$.cl echo "\n" exit 0 #