#!/usr/bin/ksh # # gen_grand_asi_display.ksh # # This script will generate an ascii display # of an inventory of various asi files # # ## Set the environment variables # if [[ -z $THMSOC ]] then THMSOC=/disks/socware/thmsoc_dp_current export THMSOC fi #. ${THMSOC}/src/config/soc_it_to_me.config . /home/thmsoc/astraea2_test/soc_it_to_me.config # ## Set current date variable # currentdate=$(date -u '+%Y%m%d') # ## Start file creation # rm -f ${LOCAL}/asi_grand_display.txt printf '\n\t >>>>> ASI Site Inventory<<<<<\n\t\t%s\n\n' "`date`" >> ${LOCAL}/asi_grand_display.txt # ## Start date loop # oldmonth=NaN for date in $(cat ${CONFIGDIR}/date_list.txt) do ## Set a start date - else 20050101 used # if (( $date < 20070215 )) then continue fi # ## Finish loop when current date reached # if [[ $date = $currentdate ]] then break fi # ## Create alternate date format - yyyy-mm-dd # date2=$(echo $date |awk '{print substr($1,1,4) "." substr($1,5,2) "." substr($1,7,2)}') # ## Insert column headers every month # newmonth=$(echo $date | awk '{print substr($1,5,2)}') if [[ $newmonth != $oldmonth ]] then yyyymm=$(echo $date |awk '{print substr($1,1,4) substr($1,5,2)}') printf "\n==============================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================\n" >> ${LOCAL}/asi_grand_display.txt printf "YYYYMMDD<>" >> ${LOCAL}/asi_grand_display.txt for site in $(cat ${CONFIGDIR}/lc_asi_site_list.txt) do printf " %-4s <>" $site >> ${LOCAL}/asi_grand_display.txt done printf "Overviews<>" >> ${LOCAL}/asi_grand_display.txt printf "\n==============================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================\n" >> ${LOCAL}/asi_grand_display.txt oldmonth=$newmonth fi printf "%s<>" $date >>${LOCAL}/asi_grand_display.txt for site in $(cat ${CONFIGDIR}/lc_asi_site_list.txt) do for dtype in $(cat ${CONFIGDIR}/asi_dtype_list.txt) do num_files=$(grep -c $date ${FILELISTS}/asi_lowrate_list_${site}_${dtype}_${yyyymm}.txt) printf "%2s-" $num_files >> ${LOCAL}/asi_grand_display.txt done ucsite=$(echo $site | awk '{print toupper($1)}') num_files=$(grep -c $date2 ${FILELISTS}/asi_summary_list_${ucsite}_${yyyymm}.txt) printf "%3s<>" $num_files >> ${LOCAL}/asi_grand_display.txt done for type in average keograms summary do num_files=$(grep -c $date2 ${FILELISTS}/asi_summary_list_${type}_${yyyymm}.txt) printf "%s-" $num_files >> ${LOCAL}/asi_grand_display.txt done printf "<>" >> ${LOCAL}/asi_grand_display.txt printf "\n------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n" >> ${LOCAL}/asi_grand_display.txt done #end date loop # ## Rename temporary file # mv -f ${LOCAL}/asi_grand_display.txt ${FILELISTS} # ## Cleanup # exit 0