#!/bin/sh
#
# get_head (version 1.0)
#
# Usage: get_head filename
#
# Where filename is: PLANT.ICC or PLANT.DBV
#
#
# By: Angel Corbera, TSID1, Refineria Isla, Curacao, N.A.
# Comments to: [email protected]
#
# This script will process the input file to extract the
# Control Block parameter NAMES, into the ascii output file
# HEADERS.TXT
#
# HEADERS.TXT will have ONE line per each Block TYPE only.
#
# HEADERS.TXT can be taken to Excel to be used with PLANT.TXT
#
if [ $# != 1 ]
then
echo "\nUsage: $0 filename"
echo "where filename = PLANT.ICC or PLANT.DBV"
exit 1
fi
cd /opt/ac
FILE=$1
echo "\nProcessing ... please wait"
awk '
{ if ( $1=="TYPE" ) print $3
else print $0
}' $FILE > tmp1
echo "\n... almost ready ..."
sed -e 's/NAME =/@NAME =/' tmp1 > tmp2
cut -c1-6 tmp2 > tmp1
sed -e 's/ *$//' tmp1 > tmp2
tr "\012" ! < tmp2 > tmp1
tr @ "\012" < tmp1 > tmp2
echo "\012" >> tmp2
sort -u -t! +1 -2 tmp2 > tmp1
sed -e 's/NAME/CP\!COMPOUND\!BLOCK/' tmp1 > HEADERS.TXT
BLOCKS=`wc -l HEADERS.TXT | awk '{print $1}'`
echo "\nHEADERS.TXT file is ready for Excel. ($BLOCKS different block types)"
rm tmp1 tmp2