#!/bin/bash # show yield stats from harvet_??.out files echo "Yield min, mean, max: _en = bu/ac, _si = kg/m^2" for infile in ${1}/harvest_en.out ${1}/harvest_si.out do if [ ! -e ${infile} ] then echo "Bad input file name. ${infile} does not exist" exit else echo "Processing ${infile}" fi crop_num=$(cat ${infile} | sed -e 's/ //g' -e 's/|/ /g' | dm N/12 | stats max) for i in $(seq 1 ${crop_num}) do let "crop_name_col = 2 + (i-1)*12" let "crop_yield_col = 9 + (i-1)*12" crop_name=$(cat ${infile} | sed -e 's/ //g' -e 's/|/ /g' | dm "if N>0 then s${crop_name_col} else SKIP" | uniq) crop_yield=$(cat ${infile} | sed -e 's/ //g' -e 's/|/ /g' | dm "if N>0 then x${crop_yield_col} else SKIP" | stats min mean max) echo "${crop_name}" echo "${crop_yield}" done done