#!/bin/ksh
########################################################################
##
## SCRIPT: listacar.sh            NCO/PMB/SDM
##
## Syntax:  listacar $1 $2
##          $1 = model hour (00 06 12 18)
##          $2 = aircraft ID (from column 1 of file LISTACARSZZ)
##
## CHANGE LOG:
##
##   04/2010   MALONE      Changed working directory from local
##                         /nco/pmb/$LOGNAME/sdmedit to /nco/ops/sdm[2]
##
########################################################################

set -xa

## DEFINE THE MACHINE AND ASSOCIATED VARIABLES.
machi=`hostname | cut -c1`
user=`whoami`
# If machi=c, then machine is cirrus. If machi=s, then machine is stratus.

## DEFINE THE WORKING DIRECTORY.
if [ $LOGNAME = 'wx12sd' ]; then
   DATA=/nco/ops/sdm   # operational wx12sd
else
   DATA=/nco/ops/sdm2   # operational wx12ss
fi
cd $DATA

## ERROR CHECK.
## Exit if 2 valid arguments are not entered.
## $1 = model hour... 00 06 12 18
## $2 = aircraft ID... found in column 1 of LISTACARSZZ
## PRESENT AIRCRAFT DATA if 2 arguments are entered.
if [ $# -ne 2 ]
then
   echo Specify model hour and aircraft ID
else
   ls -t /nco/ops/sdm/LISTACARS$1 /nco/ops/sdm2/LISTACARS$1 > filesel
   file=`head -1 filesel`
   head -3 $file > pfile
   grep -i $2 $file >> pfile
   more pfile
   rm pfile
fi

## END OF SCRIPT.
